Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I am trying to understand which data format is better on embedded device communicating with Server over REST API. XML or JSON?. Is JSON parsing faster than XML parsing in Java / C and C++? I understand for web client JSON is way to go since java script has inbuilt support for JSON but not sure about embedded device(Java/C/C++).

share|improve this question
    
It depends on the size and type of your data! –  Martijn Verburg Aug 3 '11 at 21:29
    
@Martijn : XML file size is around 50KB and there is no binary data. –  Farm Aug 4 '11 at 1:22
add comment

2 Answers

If the content has a lot of tags and not much content, JSON is better for the network because the size of the messages will be smaller. Now if the reverse is true, lots of content and not a lot of tags, JSON loses it's message size advantage somewhat, because regardless there is a large message coming across.

I am not sure about the parsing. I would load up the same XML/JSON sample data that the application would be using and run them through the parsers you are planning on using and see which one performs better.

If the parsers you are using load the XML/JSON into an object model of some sort, the performance should be about equal, but a quick test should prove if there is any real difference in parsing speed.

share|improve this answer
    
Currently there is no way to do performance testing on the device itself hence I posted question here. Thx for your answer. –  Farm Aug 3 '11 at 23:41
add comment

XML is probably better if you need to do something with the message beyond simply deserializing it (e.g., if you need to pull some routing or processing information out of it with an XPath expression). XML can give you some additional validation tools (like schema validation), and may make more sense if messages need to be archived and potentially processed again later. But if all you need is a transport format, you may be better off sticking with JSON, especially if the bulk of your processing work is going to be done on the client.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.