PROGRAMMING

 
REMEMBERS




Last update:   29-10-2021

Format

JSON (Javascript Object Notation) is a general format, Made initialy for Javascript, many other languages have libraries to handle it. Json.stringify    (2/3)

JSON.Stringify

Let’s say we have a complex object, We’d like to convert it into a string, to send it over a network. JSON.Stringify converts objects to string. The resulting json string is called a JSON-encoded or serialized. No single quotes or backticks in JSON.
 
let student = {
  age: 30,
  courses: ['html', 'css'],
};

let json = JSON.stringify(student);

console.log(typeof json); // string

alert(json); // {"age":30,"courses":["html","css"]}
... 2 lines
 
Json.parse    (3/3)

JSON.Parse

It decodes the json string.
 
let numbers = "[0, 1, 2, 3]"; // stringified array

numbers = JSON.parse(numbers);

console.log(numbers[1]); // 1

Questions    
Strings

        A B C D E F
🔔
1/2