4 ms·
I prefer JSON. Though I do agree with the other comments that xml is more readable if the structure is big, and that one can easily (and perhaps should) do both
by tmikew 17y ago
I prefer JSON. Though I do agree with the other comments that xml is more readable if the structure is big, and that one can easily (and perhaps should) do both.
In practice I have noticed that where I work we tend to have complex data structures but not very deeply nested ones. We wrote a simple find function that recursively traverses the JSON structure looking for keys. Not anything nearly as powerful as XPath but sufficient.
It tends to be highly useful in my experience to create a list of objects. For example instead of a list of phone numbers a list of phone number objects. One may then easily add attributes to the phone number. Primary, cell phone, home phone etc. This tends to be highly flexible in that attributes may be later added that were not at all considered up front.
Of course all of this can be done with xml as well. JSON just seems more convenient. If I add an attribute in Javascript or Python I can just use it and get on with it. No messing with my SaxParser or building up some new XPath. Again I am not bashing xml at all, this is just my take.
In practice we use JSON exclusively in the core services for input and output. When we need to use xml we convert it to JSON and then back to XML as a filtering process rather than fool around with our core services. This adds overhead but keeps us flexible and loosely coupled.