top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

JSON Support with Programming Languages

0 votes

JSON Support with Programming Languages

Each major programming language can incorporate JSON, which can be through either libraries or native support. However, no language can surpass JavaScript for parsing this data interchange format, which translates it directly into an object literal.

JSON is a popular as XML. Thus, each major language has one or more commonly used powerful libraries for formatting and parsing data in JSON format. Typically, only following two core functionalities are required:

  • Parse: Converts JSON data into the supported data structure of corresponding language, such as array, hash, or dictionary.
  • Format: Converts array, hash, or dictionary to JSON text.

Developers can easily find these functionalities for almost any modern language. For instance, Ruby incorporates JSON gem, Objective-C supports JSONKit, and Microsoft .NET Framework has Json.NET. Most of these libraries are fast and efficient, considering their extensive use and frequent optimizations over time.

While comparing various languages, it might be pointed out by some developers that using JSON in a C# or Java language is not practical. This is because the idioms supports statically typed classes and not objects of Dictionary or HashMap type. As a result, for generating JSON data, developers are required to use a library along with a custom code for converting these data structures to static type instances. Hence, there are some libraries created for this purpose. For instance, the Gson library from Google is designed for transforming JSON data to Java objects directly.


Gson is an open-source Java library for transforming an object in Java to JSON data and vice-versa. For this purpose, it offers easy means such as constructor (Factory Method) and toString(). This library also functions well with arbitrary Java objects, involving the pre-existing ones whose source code is not available with you. Following are the goals of Gson:

  • Converting already existing not-modifiable objects to and from JSON
  • Permitting custom representations for objects
  • Outputting legible and compact JSON data

Gson is capable of deserializing string of more than 25MB, deserializing 87,000 objects, and serializing of 1.4 million objects without any issues. Its 1.4 version has increased the deserialization bar from 80KB to more than 11MB, applicable for array and collections in bytes.

It is convenient to learn and use Gson. A developer needs to know two methods namely, toJson() and fromJson(). The toJson() method is used for transforming a Java object to JSON data whereas fromJson() for converting JSON data to an object in Java.

posted Nov 19, 2017 by Gn Guruswamy

  Promote This Article
Facebook Share Button Twitter Share Button LinkedIn Share Button

Related Articles

Comparison of JSON with Relational Databases

Although even JSON hosts or represents data, it differs significantly from the conventional relational database model implemented in RDBMS applications such as SQL Server and MySQL. Knowing these differences can help you to prefer JSON over RDBMS or vice-versa, as  per the data structure and type.

Following are the basic differences:.

  • Structure: A table stores data in a relational database, while JSON uses arrays and objects from the same, which can be recursively nested.
  • Metadata: A schema stores data about the type as well as structure of the stored data in a relational database. Further, schemas are created while creating a database and tables, not at the time of storing data. Even JSON can use a schema but it is not pre-created like in a relational database. Usually, a JSON structure is self-describing but if it uses a schema, it ensures more flexibility than a schema in a relational in a relational atabase.
  • Data Retrieval:  A relational database utilizes SQL, which is a robust and expressive language based on relational algebra, for obtaining data from tables . On the other hand, JSON does not use any popular language. In fact, it uses JSON Query Language (JAQL) and JSONiq, which are still evolving query languages.
  • Sorting: In a relational database, SQL easily helps in retrieving data and displaying it in ascending or descending order. In JSON, a developer can sort arrays.
  • Learning Curve: JSON has a much smooth learning curve. This is because the data types and structure supported here are used in several programming languages. Therefore, a developer with basic programming background grasps JSON concepts and coding quite fast. On the other hand, RDBMS is  a distinct field to learn and explore, which takes time to master. However, once mastered, it has its own opportunities and benefits to offer.
  • Application: The market has several commercial as well as open source relational databases to offer. There are also NoSQL databases but they use JSON to store data. JSON is usually implemented in several programming languages.