1

I have following array tree in json which is passed to view in a variable

   [{
       "root":"0",
       "id":"19",
       "name":"Rose",
       "childs":[{
                    "root":"19"
                    "id":"22",
                    "name":"Ceema",
                    "childs":[{
                                 "root":"22",
                                 "id":"49",
                                 "name":"Chandar"

                              },
                              {
                                 "root":"22",
                                 "id":"50",
                                 "name":"Carol"
                              }]
            },
            {
                "root":"19",
                "id":"23",
                "name":"Ben"
            }]
   }]

now i want that at first it displays the name of array with root 0, when we click on that name, it shows the name contained in arrays within child(if it has any). M not so good with json, so please help!

6
  • yes i m sending this array to view using json_ecnode(); Commented May 21, 2015 at 11:58
  • Sorry but not getting what you want to do... Commented May 21, 2015 at 12:03
  • I want a button in the middle of screen on which name given in the array with root 0 is displayed Commented May 21, 2015 at 12:05
  • use json_decode to convert into multidimensional array. Commented May 21, 2015 at 12:06
  • When we click on that button, it shows more buttons with names given in arrays of child of root 0 Commented May 21, 2015 at 12:06

1 Answer 1

1

Use json_decode() function in php or if you want to do it in javascript JSON.parse

This will give you result in array and rest things you need to do or find the code for it.

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks! Let me try :)
answer in this question might help you- stackoverflow.com/questions/11214011/…
Thanks but this is little confusing
M trying with JSON.parse because later on i have to use ajax also to submit the values

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.