JavaScript: Parse JSON – A Beginner Guide

In this tutorial, we will introduce how to parse a json string in javascript.

JavaScript: Parse JSON - A Beginner Guide

1.Prepare a json string

const jsonString = '{
  "name": "Todd",
  "age": 20    
}';

2.Start to parse json using JSON.parse()

const obj = JSON.parse(jsonString);

3.Output json information

console.log(obj.name);
console.log(obj.age);

Run this code, you will see:

Toadd
20