How to access elements of JSON object without knowing the key names
1
In this tutorial we will learn how to access elements of JSON object without knowing the key names.
Suppose the following is the JSON:
{
"d":{
"key1":"value1",
"key2":"value2"
}
}
To access the first key write::
let firstKey=Object.keys(d)[0];
To access the value of the first key write:
let firstValue= d[firstKey];