I’m trying to help a client improve the performance of their website. We’re currently building their navigation menus using XML/Javascript as their CMS doesn’t provide a server side solution that will work. First, i’m considering switching the XML to JSON as i’ve heard it’s dramatically faster so i’m curious about any feedback those of you more experienced with the infamous JSON vs. XML debate might have. Also, is the following JSON format equivalent (and correct syntax) to the XML format below it?
JSON…
[code]var departments = {
‘data’:[
{
‘title’:’Backpacks’,
‘id’:’3032′,
‘brands’:[
{‘title’:’Jansport’,’id’:’3010′}
{‘title’:’Samsonite’,’id’:’11137′}
{‘title’:’Tumi’,’id’:’11275′}
{‘title’:’Victorinox’,’id’:’3164′}
]
},
{
‘title’:’Business Cases’,
‘id’:’3131′,
‘brands’:[
{‘title’:’Ameribag’,’id’:’3173′}
{‘title’:’Atlas’,’id’:’11247′}
{‘title’:’Curtis Street’,’id’:’11217′}
{‘title’:’Hartmann’,’id’:’3007′}
]
} …
]
};
XML…
[code]<departments>
<dept id=”3032″>
<title>Backpacks</title>
<brands>
<brd id=”3010″>Jansport</brd>
<brd id=”11137″>Samsonite</brd>
<brd id=”11275″>Tumi</brd>
<brd id=”3164″>Victorinox</brd>
</brands>
</dept>
<dept id=”3131″>
<title>Business Cases</title>
<brands>
<brd id=”3173″>Ameribag</brd>
<brd id=”11247″>Atlas</brd>
<brd id=”11217″>Curtis Street</brd>
<brd id=”3007″>Hartmann</brd>
</brands>
</dept>…
</departments>