How can I parse through JSON object array in Javascript and access the values? var json = [{"employee": "John", "id":"9
Posted: Mon May 09, 2022 6:06 am
How can I parse through JSON object array in Javascript and
access the values?
var json = [{"employee": "John", "id":"97"},
{"employee": "Mary", "id": "98"}, {"employee": "Larry", "id":
"99}];
var obj = JSON.parse(json);
console.log(obj.employee);
console.log(obj.id);
I would like to be able to pull values like all employees or all
ids.
But this returns the value as 'undefined'. I need to be able to
access and use the values of the JSON object in my code. How would
I be able to efficiently do this?
access the values?
var json = [{"employee": "John", "id":"97"},
{"employee": "Mary", "id": "98"}, {"employee": "Larry", "id":
"99}];
var obj = JSON.parse(json);
console.log(obj.employee);
console.log(obj.id);
I would like to be able to pull values like all employees or all
ids.
But this returns the value as 'undefined'. I need to be able to
access and use the values of the JSON object in my code. How would
I be able to efficiently do this?