Friday 20 October 2017

Parse Json array in JavaScript

itemprop="text">




var array= [
{"Name":"Test", "Status":{"Id":100, "Alias":"A"}},

{"Name":"Test2", "Status":{"Id":101, "Alias":"B"}},
{"Name":"Test3",
"Status":{"Id":102, "Alias":"C"}}

];



How to
loop throw value of array of Name and Id in JavaScript?



Answer




array.forEach(item =>
console.log(item.Name))

array.forEach(item =>
console.log(item.Status.Id))


No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...