JSON Parsers

JSON (JavaScript Object Notation) is most popular for NoSQL data storage, data exchange format between browsers and web servers and latest framework also use for communication over networks.

For Example :

  • All latest browsers natively support parse JSON data to java script to display over page.
  • REST Service support one of MediaType is JSON to exchange data between browsers or client application to servers where these REST Services are deploy.
  • Some latest framework like Elasticsearch, Logstash, Kibana, Kafka ,Filebeat etc. are used JSON for internal storage and data exchange over network between servers.

All these above cases, JSON data language independent feature provides communication compatibility between different type frameworks and servers. All these frameworks and servers implemented by one of computer language which provides JSON API’s by internally or consumed third party library for parsing and generation.

Here we will focus mainly on Java based JSON APIs which provide various choices for parsing and JSON generation on different cases from JAVA objects.

The Java Open Source Community developed some JSON APIs which offers more choices and flexibility to work with JSON. Here is list of some well-known JSON APIS:

  • Jackson
  • GSON
  • Boon
  • JSON.org

See also : Serialization and Deserialization of JSON to/from JAVA.

JACKSON

Jackson is most popular Java JSON APIs which provide several choices to work with JSON. It contains two different parsers:

  • JsonParser : This is pull parser, which parse one token at a time. These token generated by JsonGenerator.
  • JsonMapper : This parser is use convert customize JSON to/from JAVA object. It also parse data in tree model.

You can follow this link to more detail about Jackson JSON APIs : https://github.com/FasterXML/jackson

GSON

GSON provides flexible Java JSON API developed by Google. GSON APIs are able to work with arbitrary Java objects including pre-existing objects that you do not have source code. It also supports for handling complex objects with generics and deep inheritance. GSON is having three different parsers for JSON Java APIS:

  • Gson class : It can parse JSON into custom Java objects.
  • JsonReador : It’s pull JSON parser, which parse one token at a time.
  • JsonParser : It’s parser JSON into a tree structure of GSON specific Java Objects.

You can follow this link to more detail about GSON JSON APIs : https://github.com/google/gson

Boon

Boon is a standard JSON API in Groovy . It is similar to JACKSON but not only apecific for Java JSON API. It’s complete tool kit to working with data, file process and REST services etc. Boon contains the following Java JSON parsers:

  • ObjectMapper :This parser is use to parse JSON into custom objects and Java Maps.

You can follow this link to more detail about BOON JSON APIs : https://github.com/boonproject/boon

JSON.org

JSON.org provides the first JSON API developed for Java. It’s easy to use but not flexible and fast as compared to others  Java JSON open source APIs.

As I recommend if your application is too old and using this API then only go with it otherwise you can switch with others above Java JSON APIs.

You can follow this link to more detail about JSON.org JSON APIs : https://github.com/douglascrockford/JSON-java

Here, In my further posts for JSON I will focus on JACKSON and GSON because that are most known JSON APIs used by developers.

You would like to see

Follow below link to see more about JSON Tutorial and JSON issues Solutions: