I have a JSON String like this
$test='{"var1":null,"var3":null,"status":{"code":150,"message":"blah blah"}}';
I want to access the status code in the function. this is what i tried:
$responseObj=jsonService->decode($test);//this converts the string into an Object
echo $responseObj->status->code;
now this isnt working. Can someone point me in the right direction. I think that
$responseObj->status->code
is the wrong syntax to use. What is the right syntax. I am using PHP 5.1.6 , this doesnt have the inbuilt json_decode function. So I am using a third party Class to convert. I use the following third party class
- @package Services_JSON
- @author Michal Migurski
- @author Matt Knapp
- @author Brett Stimmerman
- @copyright 2005 Michal Migurski
- @version CVS: $Id: JSON.php,v 1.31 2006/06/28 05:54:17 migurski Exp $
- @license http://www.opensource.org/licenses/bsd-license.php
- @link http://pear.php.net/pepr/pepr-proposal-show.php?id=198