How to access a member of a class which is inside another object from JSON using PHP

后端 未结 3 1966
孤城傲影
孤城傲影 2021-01-27 01:22

I have a JSON String like this

$test=\'{\"var1\":null,\"var3\":null,\"status\":{\"code\":150,\"message\":\"blah blah\"}}\';

I want to access th

3条回答
  •  旧巷少年郎
    2021-01-27 01:50

    Not sure what you're jsonService is doing but this worked for me:

    $json = '{"var1":null,"var3":null,"status":{"code":150,"message":"blah blah"}}';
    
    $result = json_decode($json);
    
    echo $result->status->code;
    

提交回复
热议问题