sanand0 / xmljson

xmlsjon converts XML into Python dictionary structures (trees, like in JSON) and vice-versa.
MIT License
121 stars 33 forks source link

Given JSON example does not convert to XML correctly #15

Closed sidhire closed 7 years ago

sidhire commented 7 years ago

The code runs as:

>>> temp = {'employees': [{'person': {'name': {'@value': 'Alice'}}}, {'person': {'name': {'@value': 'Bob'}}}]}

>>> tostring(bf.etree(temp, root=Element('root')))
'<root><employees><person><name value="Alice" /></person></employees><employees><person><name value="Bob" /></person></employees></root>'

While the example says it should convert to:

'<root><employees><person><name value="Alice" /></person><person><name value="Bob" /></person></employees></root>'

Converting this using tostring(bf.etree...) results in the correct XML:

{
  "employees": {
    "person": [
      {
        "name": {
          "@value": "Alice"
        }
      },
      {
        "name": {
          "@value": "Bob"
        }
      }
    ]
  }
}
dagwieers commented 7 years ago

Hmm, I cannot find this specific example you mention. The XML and JSON at the top of the README do seem to be correct !

sanand0 commented 7 years ago

Yes - I am unable to find the incorrect example as well. @sidhire could you please point us to where you found the example result?

dagwieers commented 7 years ago

Let's close this issue. Please reopen and provide more information if this problem still exists.

sanand0 commented 7 years ago

Agreed.