Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Jul 2013
    Posts
    48
    Thanks
    9
    Thanked 1 Time in 1 Post

    Recursion with JSON

    Hi to all. I have a JSON code. And can i take path of his childs. Something wih recursion but i cant start with anything.

    http://pastebin.com/Hd8cg1kp

  • #2
    Regular Coder
    Join Date
    Aug 2010
    Posts
    974
    Thanks
    19
    Thanked 212 Times in 210 Posts
    something similar to this ...

    Code:
     
    <!DOCTYPE html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>GetJson</title> 
    <script type="text/javascript">
    req=new XMLHttpRequest;
    req.open("GET","json.json",false);
    req.send(null);
    myObj=JSON.parse(req.responseText);
    </script>
    </head>
    <body>
    <div id="content">
    <script type="text/javascript">
    (function writeIt(obj){
    for(a in obj){ 
    if(typeof obj[a] == "object" ){
    //document.write(a,"<br>");
    document.body.appendChild(document.createTextNode(a))
    document.body.appendChild(document.createElement("BR"))
    writeIt(obj[a])
    //}
    //else document.write(a," = ",obj[a],"<br>");
    }else{
    document.body.appendChild(document.createTextNode(a+" = "+obj[a]))
    document.body.appendChild(document.createElement("BR"))
    }
    }
    })(myObj);
    </script>
    </div>
    </body>
    </html>
    http://codingforums.daveyerwin.com/val10/
    Last edited by DaveyErwin; 09-15-2013 at 11:17 PM.

  • Users who have thanked DaveyErwin for this post:

    val10 (09-16-2013)

  • #3
    New Coder
    Join Date
    Jul 2013
    Posts
    48
    Thanks
    9
    Thanked 1 Time in 1 Post
    What i have to do is, take the path of every child with recursion. In ExtJS comboBox i have to put the every child of the JSON. And when i select one, the path way is has to show below.
    My problem is with RECURSION.

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •