What is JSON | JSON explained – codewithrandom










Table of Contents

what is JSON | JSON explained

Introduction

JSON actually stands for

Java
Script
Object
Notation

and functions well as a simple format to store or transport data. JSON was found by Douglas Crockford in 2013 for the purpose to store or transport data.


Usage

JSON is used to send data from a server (backend) to a web page (frontend). JSON is considered self-describing as it’s very easy to write or read JSON. JSON is considered a string with a certain data format (text format) as it can only contain properties  and not methods.
Example

Let’s see an example use case.

‘{“name”:”Lorem”, “age”:24, “house”:null}’

This is an example JSON string that defines an object with a total of three properties that include name, age, and house. Each of these properties are given values like in this case it’s Lorem, 24 and null.

Later on we may parse this JSON string with a JavaScript code, you can access these data as an object with:

let personName = obj.name;
let personAge = obj.age;


Storing Data

Storing Data needs to be in a specified format. Regardless of where you decide to store it, text is the legal format. JSON helps by making it possible to store to store JavaScript objects in the form of text.

Why should you use JSON?

JSON format is similar to JavaScript code in terms of syntax. Furthermore, since the JSON format is text, the data in JSON can be easily sent between computers and used in any programming language.

Besides that, since the format supported is text only, JSON data can be easily transferred between computers. This means JavaScript has a feature where it can easily convert JSON to JavaScript objects via the following:

JSON.parse()


And that’s it! You have now successfully learned what is JSON!

Share on:

Leave a Comment