30 C
Saturday, May 25, 2024

What is JSON?

JSON (JavaScript Object Notation) is a text-based format for storing and transmitting structured data. It comes from the JavaScript language, but it works with almost any programming language. It is language independent. JSON has lightweight syntax. With this lightweight syntax, you can easily store and send to other apps everything from numbers and strings to arrays and objects. By using JSON, You can also create more complex data structures by linking arrays to each other.

Basic syntax and structure of JSON.

JSON text mainly has two structures:

  • a collection of key:value pairs (associative array)
  • an orderly set of values (array or list)

JSON objects are written in curly braces {}, and their key:value pairs are separated by a comma ,. The key and the value are separated by a colon :. Here is an example for you:

    “player_name”: “steve”,
    “run_scored”: 100

Keys in JSON file are always strings, but values can be any of seven types of values, including another object or array.

Arrays are written in square brackets [] and their values are separated by a comma ,. The value in the array, can be any datatypes and it is also include another array or object.

Example of array:

["day", 10, "good morning", [25, 38, "night"]]

Here is an example of JSON file containing  array as value :

    "players": [
         "player_name": "Steve",
         "run_scored": 100
         "player_name": "Robbin",
         "run_scored": 67
         "player_name": "Roy",
         "run_scored": 100

The advantages of JSON

JSON is widely used for data exchange on internet because it has strong advantages. Advantages like :

  • High readability, even people belonging to non-programming background can also read easily.
  • Compactness.
  • Flexibility.
  • Most programming languages have functions and libraries for reading and creating JSON structures.
  • After serialize data to JSON, you can deserialize it back without losing any information.

so, here is the short description of JSON. i hope you understood about JSON.

Similar Article

Also Read