sanand0 / xmljson

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

First example in README does not match xmljson behavior version 0.2.1 #47

Open chrisinmtown opened 3 years ago

chrisinmtown commented 3 years ago

The README offers the following sample XML input:

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

and JSON output:

{
    "employees": [{
        "person": {
            "name": {
                "@value": "Alice"
            }
        }
    }, {
        "person": {
            "name": {
                "@value": "Bob"
            }
        }
    }]
}

But I cannot reproduce that JSON output with version 0.2.1 (the latest), not with any of the -d options ('abdera', 'badgerfish', 'cobra', 'gdata', 'parker', 'xmldata', 'yahoo'). The option that yields the most similar output seems to be badgerfish, that produces the following list tagged "person" and containing objects that have the person data, which is a very different structure than what's shown in the README:

{
  "employees": {
    "person": [
      {
        "name": {
          "@value": "Alice"
        }
      },
      {
        "name": {
          "@value": "Bob"
        }
      }
    ]
  }
}

I didn't submit a PR correcting this because I don't know the real intent. I think the actual output is pretty confusing. Naively I expected minimal changes, with a list of "person" objects. That is arguably poor JSON (repeating the name every time) but it faithfully preserves the ugly XML input.

When the very first example is wrong, that makes the library fairly difficult to use or trust. Please reply, thanks.

chrisinmtown commented 3 years ago

The owner of this project, @sanand0, posted to #45 that he does not expect to respond to any issues before November 2020.