json get keys code example
Example 1: json get key
var jsonData = {person:"me", age :"30"};
console.log(Object.keys(jsonData)[0])
Example 2: get all keys in json object
var obj = {name: "Jeeva", age: "22", gender: "Male"}
console.log(Object.keys(obj))
Example 3: js get json keys
myObject = {
"key": "value"
}
Object.keys(myObject);
Example 4: key value json javascript
var jsonArray = '{"required":1, "minlength":2}'
var jsonParsedArray = JSON.parse(jsonArray);
for (key in jsonParsedArray) {
if (jsonParsedArray.hasOwnProperty(key)) {
console.log("%c "+key + " = " + jsonParsedArray[key],"color:cyan");
}
}