var jsonPerson = '{"first_name":"billy", "age":23}';
var personObject = JSON.parse(jsonPerson); //parse json string into JS object
const json = '{ "fruit": "pineapple", "fingers": 10 }';
const obj = JSON.parse(json);
console.log(obj.fruit, obj.fingers);
var objJson1 = JSON.parse(JSON.stringify(objNotJson1));
const json = '{"result":true, "count":42}';
const obj = JSON.parse(json);
console.log(obj.count);
// expected output: 42
console.log(obj.result);
// expected output: true
// if u have json response u can parse your json like below
getData().then(result => {
var jsonResult = JSON.stringify(result)
var parsedObject = JSON.parse(jsonResult)
parsedObject.forEach(r => {
console.log(r)
})
JSON.parse(jsonToDecode)
const obj = JSON.parse('{"key1":"val1", "key2":0.0, "key3":"00:00"}');
console.log(obj)
console.log(obj.key1)
console.log(obj.key2)
var jsonPerson = '{"first_name":"billy", "age":23}';
var personObject = JSON.parse(jsonPerson); //parse json string into JS object
var dataResult = JSON.parse(dataResult);
const parseJSON = (json) => {
return new Function('return ' + json)();
};