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'?

BERARM
  • 247
  • 1
  • 6
  • 14
  • Some gold-badge holder in the javascript tag please close this as dup. I can't since I added the javascript tag. –  Jun 24 '16 at 05:09

3 Answers3

5

console.log(JSON.parse(temp)['0_1']);

Rohit Shedage
  • 23,944
  • 1
  • 13
  • 18
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.

Property Accesors

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.

miyamoto
  • 1,540
  • 10
  • 16
0

console.log(JSON.parse(temp)['0_1']); Thanks for Rohit @Shedage @miyamoto. I tried this method is feasible。

BERARM
  • 247
  • 1
  • 6
  • 14