I have a JSON String like this
$test=\'{\"var1\":null,\"var3\":null,\"status\":{\"code\":150,\"message\":\"blah blah\"}}\';
I want to access th
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;
You can use json_decode() for this task. Also, your input string should have quotes:
$test='{"var1":null,"var3":null,"status":{"code":150,"message":"blah blah"}}';
$responseObj = json_decode($test);
echo $responseObj->status->code;
You should give PHP's json_decode() a try:
$test='{"var1":null,"var3":null,"status":{"code":150,"message":"blah blah"}}';
$responseObj = json_decode($test);
echo $responseObj->status->code;
For PEARS's Services_JSON Class (Documentation):
// create a new instance of Services_JSON
$jsonService = new Services_JSON();
$test='{"var1":null,"var3":null,"status":{"code":150,"message":"blah blah"}}';
$jsonService->decode($test);
echo $responseObj->status->code;