php json parsing objects -


i have json file need parse. i'm new php , trying figure out how correctly parse object. question is: how parse objects of object have different names

one object has name thresh next object in list has name aatrox name of top level object data

this json looks like. can access information if know name of object $champion = $jfo->data->thresh; don't want have type in names of champions. there easy way obtain separate objects without knowing names? maybe regex?

"data": {     "thresh": {         "id": 412,         "key": "thresh",         "name": "thresh",         "title": "the chain warden",         "image": {             "full": "thresh.png",             "sprite": "champion3.png",             "group": "champion",             "x": 336,             "y": 0,             "w": 48,             "h": 48         },   "aatrox": {         "id": 266,         "key": "aatrox",         "name": "aatrox",         "title": "the darkin blade",         "image": {             "full": "aatrox.png",             "sprite": "champion0.png",             "group": "champion",             "x": 0,             "y": 0,             "w": 48,             "h": 48         }, 

if want go through each champion, i'd recommend using foreach loop in php. can use such:

foreach($json->data $champion) {     // } 

Comments