JSON

What is JSON?

JavaScript Object Notation (JSON) is a text-based, schema-free representation of structured data that uses key-value pairs and ordered lists. Despite the fact that JSON is developed from JavaScript, it is supported by most major programming languages, either directly or through libraries. JSON is a standard for exchanging data between online clients and web servers that is widely used, but not entirely.

 

  • JSON is now the preferred format for practically all publicly available online services, and it is also widely used for private web services.

Many databases now handle JSON natively as a result of its popularity. JSON data may now be stored and queried natively in relational databases like PostgreSQL and MySQL. JSON is also supported by NoSQL databases like MongoDB and Neo4j, albeit MongoDB utilizes a significantly modified binary version of JSON behind the scenes.

JSON is a data format that supports just a few value types: objects, characters, lists, null values, and integers. Even though the notation is a subset of JavaScript, these kinds are represented in all mainstream programming languages, making JSON an excellent contender for data transmission across language barriers.

Importance of JSON

Due to the high expense of full-page reloads, web designers turned to emerge technologies to improve the overall user experience. Meanwhile, the ability to make background web queries while a page was being shown, which was introduced in Internet Explorer 5, was proving to be a feasible method of loading data progressively for display. Instead of restarting the full page, pressing the refresh button would send a web request to the server, which would load in the background. When the contents were loaded, JavaScript, a universal programming language for browsers, was used to alter, store, and display the data on the website.

Initially, this data was sent in XML format using the Simple Object Access Channel communications protocol. In JavaScript, however, XML was too lengthy and difficult to maintain. Because JavaScript already had objects, Douglas Crockford used a subset of that phrase as the basis for a new data transfer format called JSON.

  • JSON was significantly easier to understand and interpret for both humans and browsers.

Throughout the 2000s, a new Web services technology known as Representational State Transport, or REST, came to supplant SOAP as the preferred method of data transfer. One of the biggest benefits of utilizing REST APIs is that you may utilize a variety of data types, not only XML but also JSON and HTML. As web developers began to prefer JSON over XML, they also began to prefer REST over SOAP.

  • JSON has become the de facto standard for data exchange between online and mobile clients and back-end services.

Downsides of JSON

JSON has certain downsides, despite being a very succinct, versatile data format that is easy to deal with in many computer languages. The following are the five major drawbacks:

  • There is no way to specify a date. Because of this absence, developers must either use string representations of dates, which might cause formatting issues, or express dates in milliseconds.
  • There are no comments. This makes inline annotations difficult, necessitating extra documentation and raising the risk of misinterpretation.
  • Verbosity. JSON is less verbose than XML, although it isn’t the shortest data transmission format. You’ll want to employ more efficient data formats for high-volume or special-purpose services.
  • There isn’t a schema. On the one hand, this implies you have complete freedom in how you portray the data. On the other hand, it’s incredibly easy to produce misshaped data by mistake.

Final thoughts

If you’re building software that interacts with a browser or a native mobile app, JSON is the data format to utilize. Using an out-of-date format like XML is a red flag to front-end and mobile talent you’d otherwise like to hire.

You might be better suited utilizing a serialization framework like Apache Avro or Apache Thrift for server-to-server communication. JSON isn’t a horrible option here, and it might still be precisely what you need, but the solution isn’t as straightforward as it is for online and mobile communication.

If you’re working with NoSQL databases, you’re bound with whatever the database provides. A solid rule of thumb with relational databases that allow JSON as a type is to utilize it as little as possible. Relational databases are designed to store structured data that follows a specific format. While most now offer more flexible data in the form of JSON, searching for attributes within such JSON objects will result in a speed impact.

JSON is the de facto standard for exchanging data between web servers, browsers, and mobile apps. Its straightforward form and adaptability make it simple to read and comprehend, as well as manipulate in the programming language of your choice. The lack of a hard structure provides for more flexibility in the format, but it might be challenging to ensure that you’re appropriately reading and writing JSON