I’m developing a platform API with Java and I must choose an exchange data “protocol” to use: JSON or XML.
I’ve been googling for large coordinates representations Google maps API, MSDN bing services, SVG w3.org coordinate system and also checked some interesting stackOverflow posts: XML vs JSON and Restful API.
All the XML representations I checked used points as a unique element in the xml like this one.
<graph label="first">
<point x="11-02-2012" y="4573"></point>
<point x="12-02-2012" y="2341"></point>
<graph>
<graph label="second">
<point x="11-02-2012" y="3423434"></point>
<point x="11-02-2012" y="234243"></point>
<graph>
This is a problem for large number of points.
Then I would bet for JSON to manage plot data because I’ve used it to draw that kind of plots using JQplot plugin and it’s more comfortable to use an array of points. But the problem here is that all other components of platform API use XML templates. What would be your choice here?
JSON is significantly more terse (will use fewer characters to communicate structure), and so it might be a good efficiency choice if you’re moving lots of data. It will also be easier to code: most libraries have a function that handles the entire conversion for you.
XML will allow you to add a lot of meta-data and structure around your data. This is a benefit. But it will result in the expected performance hit.
If you anticipate sending only long lists of ordered pairs, I’d say go with JSON. Later on you can always implement an XML presentation if some legacy system demands it.
I don’t know much about the other formats you mentioned, so I can’t speak to them.