views:

272

answers:

1

Hi guys,

I'm parsing a generic JSON to a XML using net.sf.json. (I'm not using POJO Obj in the conversion)

Json that I'm converting:

{
    "root": {
        "accountId": "1000",
        "Items": [
            {
                "cost": 0.1,
                "debit": 0.1
            },
            {
                "cost": 0.2,
                "debit": 0.2
            } 
        ] 
    }
}

When dealing with vectors I'm receiving:

<root>
    <entry>
        <accountId>1000</accountId>
        <Items>
            <e>
                <cost>0.1</cost>
                <debit>0.1</debit>
            </e>
            <e>
                <cost>0.2</cost>
                <debit>0.2</debit>
            </e>
        </Items>
    </entry>
</root>

When the correct for my point of view should be:

<root>
    <entry>
        <accountId>1000</accountId>
        <Items>
                <cost>0.1</cost>
                <debit>0.1</debit>
        </Items>
        <Items>
                <cost>0.2</cost>
                <debit>0.2</debit>
        </Items>
    </entry>
</root>

Do anyone have used this lib and could help me?

Any tips could help!

Thanks in advance

A: 

Change the JSON to this format..

{ "root": { "accountId": "1000", "Items":{"Item":{"cost": 0.1,"debit": 0.1,"cost": 0.2,"debit": 0.2} } } }

Coveted