What is JSON?
- 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.
Importance of 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.
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.