JSON and Builder Libraries

 JSON stands for JavaScript Object Notation. It is a lightweight data exchange format. It is mostly used for transmitting data between servers and client applications. It is the alternative for XML because of smaller in size, faster and easier to parse. It is easily readable and writable.
It is based on a subset of the JavaScript Programming Language so it is completely language independent. But for ease of use it follows conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others.
JSON is built on two structures:
A collection of name/value pairs. In various languages, this is realized as an object, record, struct, dictionary, hash table, keyed list, or associative array.
An ordered list of values. In most languages, this is realized as an array, vector, list, or sequence.
These are universal data structures. Virtually all modern programming languages support them in one form or another. It makes sense that a data format that is interchangeable with programming languages also be based on these structures.
Here are the sample JSON format:
   "employee": {  
       "id": 1000,
       "name": "Employee A",      
       "gender": Male  

  "Employee" :  
     {"id":"1000","name":"Employee A","gender":"Male"},  
     {"id":"1001","name":"Employee B","gender":"Female"}  
There are lots of JSON builder libraries available to convert Objects into their JSON representation or vice versa. Here are the lists of some popular libraries-To go into more depth on JSON structure refer 
1.     Jackson
2.     Google-Gson
3.     Flexjson
4.     JSON.simple
5.     JSON-lib
6.     JSON-io
7.     JSON Processing
8.     Genson
While choosing a JSON library, parsing speed consideration plays an important role. Different parsing speed benchmark test concludes the libraries that performed best for big files suffered for small files and vice versa. Typical observation found that-
  • Parsing big JSON files, then Jackson and JSON-lib perform very well and most preferable library.
  • Parsing small JSON files, then Google-Gson and Flexjson perform very well and most preferable library.
  • Deal with both types of files, then JSON.simple is a good workhorse for a variable environment.

This is the basics on available popular JSON libraries.

In the continuation on JSON parsing, read another article on Parsing JSON withGson library.

To find more interesting topics on Software development follow me at https://medium.com/@ankit.sinhal

You can also find my Android Applications on play store


Popular posts from this blog

Android Performance: Avoid using ENUM on Android

Android O: Impact On Running Apps And Developer Viewpoint

Smart way to update RecyclerView using DiffUtil