org.json.JSONObject vs Gson library JsonObject org.json.JSONObject vs Gson library JsonObject json json

org.json.JSONObject vs Gson library JsonObject


Following are the main differences:

1) GSON can use the Object definition to directly create an object of the desired type. JSONObject needs to be parsed manually.

2) org.json is a simple, tree-style API. It's biggest weakness is that it requires you to load the entire JSON document into a string before you can parse it. For large JSON documents this may be inefficient.

3) By far the biggest weakness of the org.json implementation is JSONException. It's just not convenient to have to place a try/catch block around all of your JSON stuff.

4) Gson is the best API for JSON parsing on Android. It has a very small binary size (under 200 KiB), does fast databinding, and has a simple easy-to-use API.

5) GSON and Jackson are the most popular solutions for managing JSON data in the java world.


Many JSON implementations are available in the market and most of them are open source. Each one has specific advantages and disadvantages.

  • Google GSON
  • Jackson
  • org.json etc.

Google GSON click for official documents

  • Provide simple toJson() and fromJson() methods to convert Java objects to JSON and vice-versa
  • Allow pre-existing unmodifiable objects to be converted to and from JSON
  • Extensive support of Java Generics
  • Allow custom representations for objects
  • Support arbitrarily complex objects (with deep inheritance hierarchies and extensive use of generic types)

Jackson click for official documents

  • Streaming API or incremental parsing/generation: reads and writes JSON content as discrete events
  • Tree model: provides a mutable in-memory tree representation of a JSON document
  • Data binding: converts JSON to and from POJO’s

Some comparison blogs click here blogs1, blog2

I personally done a benchmark for serialization and deserialization using GSON vs Jackson vs Simple JSON

  • Very small object: Google gson performs faster than Jackson and Simple JSON
  • Large objects : Google gson performs faster than Jackson and Simple JSON


I did experiment with 456 Kb json file on real Pixel 3 device Android 11.I need to create a backup file from database. Model has 3 objects with one-to-many relationships: Note, Item, Alarm.

Note -> fields and List<Item>.Item -> fields and List<Alarm>.Alarm -> fieldsSerialization result:gson -> 75ms; org.json -> 63msgson -> 83ms; org.json -> 67msgson -> 73ms; org.json -> 62ms

As you can see the default android org.json is faster than GSON.If you have a time to create a mapping for your model, I recommend using the default org.json.If you want to create json faster than gson, but more easy than org.json try using moshi or maybe kotlinx-serialization.