var temp = '{"name":"abc","0_1":"padforn"}';
console.log(JSON.parse(temp).name);
console.log(JSON.parse(temp).0_1);
The temp
variable has two keys.
Please how to get the value use key '0_1'?
var temp = '{"name":"abc","0_1":"padforn"}';
console.log(JSON.parse(temp).name);
console.log(JSON.parse(temp).0_1);
The temp
variable has two keys.
Please how to get the value use key '0_1'?
You can access it with JSON.parse(temp)['0_1']
as Rohit says. Note that in order to use dot notation, the identifier cannot start with a number.
In this code, property must be a valid JavaScript identifier, i.e. a sequence of alphanumerical characters, also including the underscore ("_") and dollar sign ("$"), that cannot start with a number. For example, object.$1 is valid, while object.1 is not.
console.log(JSON.parse(temp)['0_1']); Thanks for Rohit @Shedage @miyamoto. I tried this method is feasible。