Skip to content

Instantly share code, notes, and snippets.

@Hamled
Created January 9, 2016 00:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hamled/076c4c6ca253cb852981 to your computer and use it in GitHub Desktop.
Save Hamled/076c4c6ca253cb852981 to your computer and use it in GitHub Desktop.
Two different ways to convert an XML document to JSON
<petStore>
<pets>
<dog>
<id>515</id>
<name>Rusty</name>
<breed>ChocolateLabrador</breed>
</dog>
<dog>
<id>516</id>
<name>Lulu</name>
<breed>Chihuahua</breed>
</dog>
<cat>
<id>572</id>
<name>Peanut</name>
<breed>Birman</breed>
</cat>
</pets>
</petStore>
{
"petStore": {
"pets": {
"dogs": [{
"id": 515,
"name": "Rusty",
"breed": "ChocolateLabrador"
}, {
"id": 515,
"name": "Lulu",
"breed": "Chihuahua"
}],
"cats": [{
"id": 572,
"name": "Peanut",
"breed": "Birman"
}]
}
}
}
{
"petStore": {
"pets": [{
"type": "dog",
"id": 515,
"name": "Rusty",
"breed": "ChocolateLabrador"
}, {
"type": "dog",
"id": 516,
"name": "Lulu",
"breed": "Chihuahua"
}, {
"type": "cat",
"id": 572,
"name": "Peanut",
"breed": "Birman"
}]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment