JSON  - A Quick Guide

JSON - A Quick Guide

This blog covers the fundamentals of JSON

ยท

2 min read

Hey Folks!! ๐Ÿ‘‹

In this blog, you'll learn the basics of JSON

But Wait, what is JSON?

JSON stands for Javascript Object Notation and is a lightweight text-based open standard designed for human-readable data interchange. It can be used with any Programming language to interchange data!!

Quick Tour of JSON:

  • JSON stands for JavaScript Object Notation.
  • It has been extended from the JavaScript scripting language.
  • The filename extension is .json.
  • It was designed for human-readable data interchange.

Usage of JSON:

  • JSON format is used to exchange data.
  • Is primarily used to transmit data from server to web-apps
  • Is used by APIS to provide data
  • Can be used with modern programming languages

Alright, now let's jump straight to JSON!!

JSON - Syntax

  • Data is represented in key/value pairs, similar to dictionaries in Python!
  • Curly braces hold objects and each key is followed by a colon (:).
  • Key/Values pairs are separated using commas.

JSON - Data Types:

  • Number
  • String
  • Boolean
  • Array
  • Value
  • Object
  • null

๐Ÿ’ก Numbers:

Syntax:

let objName = {string: number_value, ...}

Example:

let obj = {marks: 97}

Strings:

Syntax:

let objName = {string: "string_value", ...}

Example:

let obj = {name: "Anurag"}

Booleans:

Syntax:

let objName = {string: true/false, ...}

Example:

let obj = {loves_creating: true}

Arrays:

Syntax:

let objName = {string: [ values ], ...}

Example:

let obj = {movies: ["Inception", "The Revenant", "Parasite"]}

Obejcts:

Syntax:

let objName = {string: value, ...}

Example:

let obj = {
"id": 5,
"name": "Johsua",
"rank": 1
}

Null:

Syntax:

let objName = {string: null, ...}

Example:

let obj = {license: null}

An example of JSON:

{
   "book": [

      {
         "id": "01",
         "language": "Java",
         "edition": "third",
         "author": "Herbert Schildt"
      },

      {
         "id": "07",
         "language": "C++",
         "edition": "second",
         "author": "E.Balagurusamy"
      }

   ]
}

That's all for this blog folks. Drop some hearts ๐Ÿ’– if you liked it!!

cool

Author:

- Anurag

- Github

- Twitter

- LinkedIn

- Hashnode

Did you find this article valuable?

Support Anurag's Blog by becoming a sponsor. Any amount is appreciated!

ย