Learn JSON from Scratch

What is JSON?🤔

JSON (JavaScript Object Notation) is a lightweight data-interchange format.
JSON is easy for humans to read and write, yet it is efficient enough for computers to handle.
JSON is commonly used for transmitting data in web ap…


This content originally appeared on DEV Community 👩‍💻👨‍💻 and was authored by Mahmoud EL-kariouny

What is JSON?🤔

  • JSON (JavaScript Object Notation) is a lightweight data-interchange format.

  • JSON is easy for humans to read and write, yet it is efficient enough for computers to handle.

  • JSON is commonly used for transmitting data in web applications (e.g., sending some data from the server to the client, or passing state information between the two) and for serializing structured data into a string representation.

  • It can be used to represent numbers, strings, booleans, arrays, objects, and raw bytes in a standardized way.

  • JSON is often used to output data in the Web API's response body.

Advantages of using JSON

  • JSON is an open standard that enables data to be exchanged between applications without the need for a middleman.

  • JSON is easy for humans to read and write, which makes it ideal for data exchange between different applications.

  • JSON is more compact than XML, and therefore easier to transmit.

  • It is supported by all programming languages.

  • It can be used on all platforms.

  • It is a light weight database standard, so data transmission is fast.

Where JSON is used?

  • JSON is used as the data format for many web services and APIs, such as GitHub, Netflix, Twitter and Facebook

  • Mobile Applications

  • Gaming API's

Data types supported

  1. String
  2. Number
  3. Arrays
  4. Null
  5. Boolean
  6. Object

JSON methods in JavaScript

  1. JSON.parse(): Takes JSON string and convert into JavaScript object.

  2. JSON.stringify(): Convert JavaScript object JSON into JSON string useful while sending over the network.

Syntax and Example

{
  "squadName": "Super hero squad",
  "homeTown": "Metro City",
  "formed": 2016,
  "secretBase": "Super tower",
  "active": true,
  "members": [
    {
      "name": "Molecule Man",
      "age": 29,
      "secretIdentity": "Dan Jukes",
      "powers": ["Radiation resistance", "Turning tiny", "Radiation blast"]
    },
    {
      "name": "Madame Uppercut",
      "age": 39,
      "secretIdentity": "Jane Wilson",
      "powers": [
        "Million tonne punch",
        "Damage resistance",
        "Superhuman reflexes"
      ]
    },
    {
      "name": "Eternal Flame",
      "age": 1000000,
      "secretIdentity": "Unknown",
      "powers": [
        "Immortality",
        "Heat Immunity",
        "Inferno",
        "Teleportation",
        "Interdimensional travel"
      ]
    }
  ]
}

Connect with Me 😊


This content originally appeared on DEV Community 👩‍💻👨‍💻 and was authored by Mahmoud EL-kariouny


Print Share Comment Cite Upload Translate Updates
APA

Mahmoud EL-kariouny | Sciencx (2022-10-14T01:17:06+00:00) Learn JSON from Scratch. Retrieved from https://www.scien.cx/2022/10/14/learn-json-from-scratch/

MLA
" » Learn JSON from Scratch." Mahmoud EL-kariouny | Sciencx - Friday October 14, 2022, https://www.scien.cx/2022/10/14/learn-json-from-scratch/
HARVARD
Mahmoud EL-kariouny | Sciencx Friday October 14, 2022 » Learn JSON from Scratch., viewed ,<https://www.scien.cx/2022/10/14/learn-json-from-scratch/>
VANCOUVER
Mahmoud EL-kariouny | Sciencx - » Learn JSON from Scratch. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/10/14/learn-json-from-scratch/
CHICAGO
" » Learn JSON from Scratch." Mahmoud EL-kariouny | Sciencx - Accessed . https://www.scien.cx/2022/10/14/learn-json-from-scratch/
IEEE
" » Learn JSON from Scratch." Mahmoud EL-kariouny | Sciencx [Online]. Available: https://www.scien.cx/2022/10/14/learn-json-from-scratch/. [Accessed: ]
rf:citation
» Learn JSON from Scratch | Mahmoud EL-kariouny | Sciencx | https://www.scien.cx/2022/10/14/learn-json-from-scratch/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.