aug born
aug born

Reputation: 346

Unable to fetch values from json array tree in codeigniter

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!

Upvotes: 1

Views: 190

Answers (1)

Satish
Satish

Reputation: 1012

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.

Upvotes: 1

Related Questions