vinitkumar / json2xml

json to xml converter in python3
https://json2xml.readthedocs.io/
Other
98 stars 32 forks source link

dicttoxml - @attrs not escaping key:value pairs at all #199

Open ssnyder opened 6 months ago

ssnyder commented 6 months ago

given the following JSON:

"TagGroup": {
     "@attrs": {
          "Name": "systemSpec",
          "HelpText": "spec version <here>"
     }
}

I load a dictionary as follows:

info_dict['Info']={
    "@attrs":{"Name": "systemSpec",
    "HelpText": "spec version <here>"}
}

I then call: output_xml = json2xml.dicttoxml.dicttoxml(info_dict, attr_type=False, item_wrap=False, root=False)

Expected Results: <Info Name="systemSpec" HelpText="spec version &lt;here&gt;" />

Actual results: <Info Name="systemSpec" HelpText="spec version <here>" />

If there was some way for us to enable/disable the contents of the @attrs to be escaped, that would be great. Even if it is document-wide, it would be a big help to me. My workaround for now, is to do the escaping when building the dictionary, but it should be handled within the dicttoxml call, not in my code.

vinitkumar commented 6 months ago

@ssnyder Let me look into this and get back to you on this.