Parsing JSON in JavaScript is an easy process and can be done by using the JSON.parse() function built into the JavaScript language.
Here’s a basic example:
```
// Assume this is a string received from a web server
let jsonStr = ‘{“name”: “John”, “age”: 30, “city”: “New York”}’;
// Use JSON.parse() to convert the string into an object
let jsonObj = JSON.parse(jsonStr);
// Now jsonObj is an object that can be used in JavaScript:
console.log(jsonObj.name); // output: John
console.log(jsonObj.age); // output: 30
console.log(jsonObj.city); // output: New York
```
In this example, we first declare a string that’s formatted as a JSON object. We then use JSON.parse() to convert that string into an actual JavaScript object, which we can access and manipulate as we would with any other JavaScript object.
Please note that in JSON, properties must be enclosed in double quotes, single quotes can’t be used.
Moreover, the JSON.parse() method can optionally use a second parameter, a reviver function that allows performing transformations on the resulting object before it’s returned. For example:
```
// Let’s assume each person object has a date of birth as a string
let jsonStr = ‘{“name”: “John”, “dob”: “2000-01-01T00:00:00.000Z”}’;
let jsonObj = JSON.parse(jsonStr, (key, value) => {
if (key === “dob”) return new Date(value);
else return value;
});
console.log(jsonObj.dob); // output: Sat Jan 01 2000 (whatever your time zone is)
```
In the above example, the reviver function transforms the dob property into a Date object, making it easier to be manipulated later.