I have a json like so:
json = { "key1" : "watevr1", "key2" : "watevr2", "key3" : "watevr3" }
Now, I want to know the index of a key, say "key2" in json - which is 1. Is there a way?
I have a json like so:
json = { "key1" : "watevr1", "key2" : "watevr2", "key3" : "watevr3" }
Now, I want to know the index of a key, say "key2" in json - which is 1. Is there a way?
Its too late, but it may be simple and useful
var json = { "key1" : "watevr1", "key2" : "watevr2", "key3" : "watevr3" };
var keytoFind = "key2";
var index = Object.keys(json).indexOf(keytoFind);
alert(index);