Skip to content
This repository was archived by the owner on Jan 8, 2026. It is now read-only.
This repository was archived by the owner on Jan 8, 2026. It is now read-only.

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

@chrisinmtown

Description

@chrisinmtown

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.

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