How read dynamic keys in JSON , NodeJs and or JQuery and or JavaScript?
I did not find. I did try.
Need find out name keys, and read values.
Keys dynamic
{
"marka1": {
"name": "Mika",
},
"beti1": {
"name": "Yii",
}
}
How read dynamic keys in JSON , NodeJs and or JQuery and or JavaScript?
I did not find. I did try.
Need find out name keys, and read values.
Keys dynamic
{
"marka1": {
"name": "Mika",
},
"beti1": {
"name": "Yii",
}
}
Need find out name keys, and read values.
var obj = {
"marka1": {
"name": "Mika",
},
"beti1": {
"name": "Yii",
}
};
you can get the keys inside this object by
var keys = Object.keys( obj);
console.log(keys);
now you can iterate this keys
array to get values of each property.
The "key" should be a property of the object and not the name of the object. The data structure should look more like :
[ { key : "marka1", name : "Mika" } ]
With it being an array of objects, this will allow you to reference the key of each object.
If the data is formatted like that, use Object.keys() https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys to grab the key