Skip to content

json to xml conversion with custom xml namespace #33

@althaf004

Description

@althaf004

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions