views:

18

answers:

1

It might be a frequent question but i cannot figure out how to prevent errors in my parsing when the script can't find a property...

in XML was easy because even the empty properties were like <location/>

but now if location is not available JSON paser cant find it and it results in errors...OR

it may happen the json has different property or a children lost its father..... so for instance if you need to extract the LocalityName is no more under SubAdministrativeArea but under AddressLine...

any of you have any experience about? what the best way to solve it and to parse it correctly?

A: 

If I get this right and you are using a library to convert to json like gson try to construct some kind of object array like arrayList in java and then convert to json so every object you retrieve later in javascript is distinct and thus clear during debugging.Also if you don't use firebug give it try as it shows json data clearly.cheers

Argiropoulos Stavros