Groovy parsing JSON vs XML

Using groovy, do you expect better performance in terms of speed and memory overhead for reading and querying JSON vs XML?

+4
source share
5 answers

JSON is smaller and simpler than XML. I bet that JSON understands faster.

YAML will be faster.

+5
source

If speed were really a problem, I'd rather use the java library for parsing than I want than relying on the Groovy implementation.

+2
source

If this is the same scheme and the same information, then the memory usage will be approximately the same. Performance should be negligible between the two.

+2
source

I believe that the difference in performance will be undetectable to anyone but the profiler if the schema and data are the same. However, you noticed a big difference if you used the wrong XML parser. In other words, an SAX implementation can easily match or possibly outperform JSON parsing. There are many external factors that may be helpful. If you want the real story to throw both JSON and SAX parser into the same data / schema without additional logic. Big savings come from the logic used to interpret the parsing. It may be easier to use DOM or pull parsing depending on your requirements, while SAx will cause an overly complex inefficient solution. There are also noticeable differences between parsers. Add a file size variable and you will quickly lose the volume of what you are actually measuring. Another example: if your XML contains DTD descriptions and entity references that must be resolved by wire, and your network connection has a high latency, then you can see improvements in JSON. It all comes down to what you are really trying to do.

+2
source

XML has a bit more overhead than JSON due to angle brackets and additional information and what not. For this reason, any good parser should be able to parse JSON faster than XML.

+1
source

Source: https://habr.com/ru/post/1277544/


All Articles