JSON !!!

It's a structured text-based format, used for data exchange

  • turned_in_notJson ?
    • Stands for JavaScript Object Notation
    • Most widely used for data exchange
    • Also used by many programing languages
    • File Extension: .json
    • Json format was specified by Douglas Crockford
    • Remember! It's just a simple text but in a structured form
Example:
  • turned_in_notSimple Json code
    { "name":"Rahul", "age":23, "education":"B.Tech" }
    

Write Your First Script!

Below, only one way is shown to write and run Json in your HTML Web Page, more will come in coming section

Steps:
  • turned_in_notOpen Your Text Editor
    • Here, we are using Notepad as a text editor and Windows as an operating System
    • Option 1: Desktop Screen->Right Click->New->Select Text Document
    • Option 2: Start button->Search Notepad
    • Option 3: Press Windows Button + R -> Type Notepad-> Press Enter
    • You can try any of the above option, And for other text editors you just open the editor
  • mode_editWrite your Json code
    • You can write or copy the code in your text editor
    <!DOCTYPE html>
    <html>
    <head><title>Json sample example</title></head>
    <body>
    <p>My Name is <span id="show"></span></p>
    <script>
      //variable having JSON code
      var jsonSample = '{ "name":"Rahul", "age":23, "education":"B.Tech" }';
      var obj = JSON.parse(jsonSample);
      document.getElementById("show").innerHTML = obj.name;
    </script>
    </body>
    </html>
    
  • descriptionSave the file
    • You save the file with html extension (.htm or .html)
    • Since here, we are declaring JSON inside HTML code
  • doneRun your saved file in the browser

    Open the saved file in your browser!

    OUTPUT:

    My Name is

    • Bingo! you have just write and run your Json code within HTML
  • JSON Syntax
Next ❯Syntax
receipt
❯