How to i access JSON key, for instance
myObj = {"name":"John", "age":30}
var obj = JSON.parse(myObj);
i want to print name.
i know to access value you can do.
obj.name
but i want to access the key, i want to print something like
name: John
How to i access JSON key, for instance
myObj = {"name":"John", "age":30}
var obj = JSON.parse(myObj);
i want to print name.
i know to access value you can do.
obj.name
but i want to access the key, i want to print something like
name: John
The easiest way is probably to use Object.entries method.