Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

json to xml conversion with custom xml namespace #33

Open
althaf004 opened this issue Nov 23, 2021 · 0 comments
Open

json to xml conversion with custom xml namespace #33

althaf004 opened this issue Nov 23, 2021 · 0 comments

Comments

@althaf004
Copy link

Hi, i need to convert a json data to xml. the sample code is as below.

from json2xml import json2xml
from json2xml.utils import readfromurl, readfromstring, readfromjson
data = readfromstring(

 '{"ra:covered-product-agreement":{"login":"mojombo","id":1,"avatar_url":"https://avatars0.githubusercontent.com/u/1?v=4"}}'
)
return json2xml.Json2xml(data, attr_type=False).to_xml()

where "ra" is the namespace. but the conversion is not exactly happening.

the result expecting is

<ra:covered-product-agreement>
		<login>mojombo</login>
		<id>1</id>
		<avatar_url>https://avatars0.githubusercontent.com/u/1?v=4</avatar_url>
	</ra:covered-product-agreement>

with current version the result received is


<key name="ra:covered-product-agreement">
		<login>mojombo</login>
		<id>1</id>
		<avatar_url>https://avatars0.githubusercontent.com/u/1?v=4</avatar_url>
	</key>

Please suggest a way to achieve this using

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant