The situation is this. JSON parshu:

"rates": { "ИМЯ": 9.049538, "ИМЯ": 5232.196666, "ИМЯ": 5.3593, "ИМЯ": 322.387247 } 

I need to get both the name and the value, if everything comes out simple with the value (data.rates.NAME), then the problem comes up with the name. Is it possible?

Thanks in advance for the answer!

  • your JSON is not valid, the same keys are parsed in Object {rates: Object} rates: Object NAME: 322.387247 - zb '
  • This is a piece of JSON, it is not complete. Just did not see the point of merging the rest of the data, they only spoil the picture. - andrewshka
  • Advice - when giving an example, always make sure that there is no conflicting data - identical keys and the like, a piece of the structure is good - so make it valid. - zb '
  • one
    It seems to me that this is not important. And your advice - the usual nagging. Just do not understand - why? - andrewshka

1 answer 1

 var obj = { 0 : "a", 1 : "b", 2 : "c"}; alert(Object.keys(obj)); // will alert "0,1,2" 

Object.keys ()

Although I did not understand what it means to "parse JSON".

  • Thank! A "parshu" from the word "parsit" :) I apologize, did not know how to put it differently. - andrewshka
  • I understood the word. That's not the point. Parsing is an analysis of the structure, and in the case of JSON, you don’t need to analyze anything; this is the native representation of the object in text form. - Zhukov Roman
  • Strangely, I always understood by the word "parsit" to "take data from somewhere." But I understood what you meant. - andrewshka