top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Advantages of JSON

0 votes
852 views

Advantages of JSON

                                                           

JSON is primarily used for serializing and de-serializing data being sent to and from an application made using JavaScript. Considering this fact, the advantages of JSON relate to the use of JSON over other option for serialization  and de-serialization.

Typically, in an XML environment, the sender  encodes the data to serialized, by using a DTD that the recipient can comprehend. This task involves a lot of additional padding around the data, regardless of which DTD in use. Thus the size of the XML documents  is significantly  larger than the actual data values to be sent. Then, the recipient obtains the XML data stream and decodes it for putting in the memory.

Comparatively, this process of serialization if done through JSON is quicker and more compact due to the format’s inherent structure. JSON structure uses standard programming data types whose structure is simple to understand. Further, the encoding mechanism is efficient enough to add only minimum characters required to reflect the structure and data values. When the recipient obtains this serialized data, the only procedure required is to evaluate the text through a compatible function in any programming language. For example, evaluation can happen by using eval function of JavaScript.

The other standard to compare is Yaml Ain’t Markup Language (YAML) that serializes  complex data sets without a DTD and relies on a simpler parser than XML. Even such a parser consumes more time than JSON to output larger streams of serialized data.

Following are some more benefits of using JSON:

  • JSON parses faster than XML and YAML.
  • JSON is simpler to work with some languages such as PHP, Python, and JavaScript.
  • JSON is  simpler to map to an object oriented system, as it is data-oriented.
  • JSON is a valid subset of even Python and YAML apart from JavaScript.
  • JSON easily differentiates between the string ‘2’ and the number ‘2’ as well as between a single item and a collection of size one (array).
  • JSON is an ideal data exchange format, and not an ideal document exchange format as XML. Thus, it is not necessary for JSON to be extensible for exchanging documents by defining new tags for representing data.
posted Nov 13, 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.
READ MORE
...