JSON or JavaScript Object Notation is a lightweight text-primarily based open general designed for human-readable information interchange. Conventions utilized by JSON are recognized by programmers, which consist of C, C++, Java, Python, Perl, etc.
Uses of JSON
Characteristics of JSON
Easy Example of JSON
The below given example below represents how to make use of JSON to store information associated with books based on their topic and edition.
{ "book": [ { "id":"01", "language": "Java", "edition": "third", "author": "Herbert Schildt" }, { "id":"07", "language": "C++", "edition": "second", "author": "E.Balagurusamy" } ] }
We will try some other examples. After interpretation of the above program. Let's save the code below as json.htm.
<html> <head> <title>JSON example</title> <script language = "javascript" > var object1 = { "language" : "Java", "author" : "herbert schildt" }; document.write("
"); document.write("
"); document.write("
+ object1.language+""); document.write("
+ object1.author+""); var object2 = { "language" : "C++", "author" : "E-Balagurusamy" }; document.write("
"); document.write("
+ object2.language+""); document.write("
+ object2.author+""); document.write("
"); document.write(object2.language + " programming language can be studied " + "from book written by " + object2.author); document.write("
"); </script> </head> <body> </body> </html>
Now let's try to start json.htm using IE or any other javascript qualify browser that generates the below-given result:
You can refer to the JSON Objects chapter for more information on JSON objects.