Topic
No replies
SystemAdmin
SystemAdmin
6772 Posts
ACCEPTED ANSWER

Pinned topic Converting XML to JSON

‏2013-01-22T11:10:33Z |
Hi,

I am using the attached xsl to convert xml to json.The xsl works fine to form an Array in json when the request is in below format, where parent to form an Array has all child with the same name

<Customers>
<Customer Id="99">
<Name>Bob</Name>
<Age>39</Age>
<Address>
<Street>10 Idle Lane</Street>
<City>Yucksville</City>
<PostalCode>xxxyyy</PostalCode>
</Address>
</Customer>
<Customer Id="101">
<Name>Bill</Name>
<Age>39</Age>
<Address>
<Street>10 Idle Lane</Street>
<City>Yucksville</City>
<PostalCode>xxxyyy</PostalCode>
</Address>
</Customer>
</Customers>

but if the parnet node has some repating child and some non repeating ,eg

<Customers>
<Child1>Child1</Child1>
<Child2>Child1</Child2>
<Customer Id="99">
<Name>Bob</Name>
<Age>39</Age>
<Address>
<Street>10 Idle Lane</Street>
<City>Yucksville</City>
<PostalCode>xxxyyy</PostalCode>
</Address>
</Customer>
<Customer Id="101">
<Name>Bill</Name>
<Age>39</Age>
<Address>
<Street>10 Idle Lane</Street>
<City>Yucksville</City>
<PostalCode>xxxyyy</PostalCode>
</Address>
</Customer>
</Customers>
The converted JSON is not a proper one.

Does any one have any xlst to convert xml to json that is generic?