Speed ​​up JSON objects

I am using the org.json library. * to translate the results of my web services (obviously json) into json objects. My problem is that the JSONObject and JSONArray constructors take a long time to build objects. I do not transmit a very large amount of data (somewhere between 1 and 100 elements of the array with 3-5 keys each), but even with 4 or 5 it takes several seconds to complete the constructor.

Is there any way to speed this up? Is there a faster library that I could use?

There is not much code here.

JSONArray arrayjson = new JSONArray(json); 

Where json is the string.

+4
source share
2 answers

You can try gson . This article indicates that it has pretty good performance for Android and other alternatives. Jackson might be another good alternative.

+3
source

According to the results of https://github.com/eishay/jvm-serializers/wiki for serialization with linking to files with strings, for example gson.toJson (myObject), Gson is more than 10 times slower than Jackson. FastJSON beat Jackson in the same test by 2-3%.

The deserialization efficiency is similar: Gson is over 9 times slower than Jackson, and FastJSON is about 0.5% faster than Jackson.

Note. The current test results used Gson 1.6. With Gson 1.7.1, data binding performance improved by 10-15% compared to Gson 1.6 (but manual and manual / tree solutions showed no improvement). Results are expected to be updated soon.

+3
source

All Articles