mercredi 27 juillet 2016

read json object in php

I have some json object like this:

{"g_aaa77":
    {"'title'":"title2",
        "'r_a6cff'":                
            {"name":"name2","price":"2"},
        "'r_7fc7b'":   
            {"name":"name22","price":"22"}
     },
 "g_a36b5":
     {"title":"title1",
         "r_4e122": 
             {"name":"name1","price":"1"},
         "r_155fa":
             {"name":"name11","price":"11"}
     }
}

g_aaa77 and g_a36b5 are a random string.

Also r_a6cff,r_7fc7b,r_4e122,r_155fa

How can I read this json?

Normally is this way:

$json = { .. };

$json->g_a36b5->title;

But I do not have 'g_a36b5'. it is a random string.

maybe I must convert this json to another or something like this.

can u please tell me how can I read this json?

Aucun commentaire:

Enregistrer un commentaire