#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    29
    Rep Power
    0

    How to get elements of JSON except the first one


    Title is clear enough. I have JSON and i want to get all of the elements of specific directory, except first one.
    Code:

    Code:
    "columns": 
    [{"name":"Language"}, 
    {"name":"Speakers_2008"},
     {"name":"Speakers_2009"}, 
    {"name":"Speakers_2010"}]},
  2. #2
  3. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    Google is your friend.

    Comments on this post

    • web_loone08 agrees
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  4. #3
  5. A Not To Shabby Code Smurf
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Aug 2008
    Posts
    1,187
    Rep Power
    184
    You would do it like this:
    Code:
    <script>
    
    var all_cols = { "columns": 
     [
      {"name":"Language"}, 
      {"name":"Speakers_2008"},
      {"name":"Speakers_2009"}, 
      {"name":"Speakers_2010"}
     ]
    };
    
    var maxlen = all_cols.columns.length;
    
    for(i=1;i<maxlen;i++){
     alert(all_cols.columns[i].name);
    }
    
    </script>
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    29
    Rep Power
    0
    i search in google, read articles read common posts, but cant understand him.
  8. #5
  9. A Not To Shabby Code Smurf
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Aug 2008
    Posts
    1,187
    Rep Power
    184
    Originally Posted by val10
    i search in google, read articles read common posts, but cant understand him.
    Take a look at this and you will see how it work:http://www.json.org/js.html. Basically..., the example that I altered from your example; deals with a "multi-dimensional object" / "multi-dimensional array". You could also do some online research regarding those key terms. Do some research about how you access multi-dimensional objects/arrays; that should give you a better perspective, on how to access JSON with JavaScript.
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    29
    Rep Power
    0
    this solve my problem. Thanks.

IMN logo majestic logo threadwatch logo seochat tools logo