Access JSON Object with Bracket Notation
The easiest way to access JSON Object Keys is to use bracket notation (using square bracket) and it's as follows.
var tom = { "id": "111", "No. of siblings": "5" } console.log(tom["No. of siblings"]);
Accessing Nested Array with Bracket Notation
The same goes for accessing nested arrays, you can use the array index and then refer to the array notation to get the empty spaces.
var toms = [ { "id": "111", "No. of siblings": "5" }, { "id": "112", "No. of siblings": "3" }, ]; console.log(toms[0]["No. of siblings"]);
Leave a reply