Loop through Json object

Posted by Tanmoy on Stack Overflow See other posts from Stack Overflow or by Tanmoy
Published on 2009-03-26T06:01:47Z Indexed on 2010/03/13 11:45 UTC
Read the original article Hit count: 284

Filed under:
|

I have a JSON object like the following

 var p =
    {
        "p1": "value1",
        "p2": "value2",
        "p3": "value3"
    };

Now I want to loop through all p elements (p1,p2,p3...) and get their key and values. How can I do that? I can modify the Json object if necessary . My ultimate goal is to loop through some key value pairs. And if possible I want to avoid using eval.

© Stack Overflow or respective owner

Related posts about JSON

Related posts about JavaScript