W
W
WhiteSama2015-03-17 18:27:54
JavaScript
WhiteSama, 2015-03-17 18:27:54

How to pull the Json index of an array by its ordinal?

How to find the Json index of an array by its ordinal?

I have an array of format:

array(10) {
   [2056]=>
        array(1) {
             ["id"]=>
                 string(2) "3"
    [2096]=>
         array(7) {
                  ["id"]=>
                         string(2) "7"


I need to pull out "2056", "2096" in a loop (I parsed the necessary data, but I need this index as an id), so that I can use it further in a GET request.
Json is not mine, I can't change it. I do it with Jquery.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Novikov, 2015-03-17
@BOOMER_74

Have you tried for in?

for (var key in { 2001: {}, 2002: {} }) {
    console.log(key);
}

W
whats, 2015-03-18
@whats

What you need

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question