Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

XML to Json - Array name missing?

Help
Kevin
2009-08-11
2013-04-29
  • Kevin
    Kevin
    2009-08-11

    I have this XML
    <e>  <a>text</a>  <a>text</a> </e>

    when I use XMLSerializer to do the conversion to JSON, i got
    {"e": [
        "text",
        "text"
    ]}

    the array name 'a' is missing...

    but if I have <e id='2'>  <a>text</a>  <a>text</a> </e>
    I got
    {"e": {
        "@id": "2",
        "a":     [
            "text",
            "text"
        ]
    }}

    "a" is back.. Is there is a way to always have my array name regardless if the element has an attribute or not?