BR
asked on
php json_decode
Dear Experts,
I use PHP and get the data like below.
$obj = json_decode($server_output );
echo $output= $obj->result;
//the out put is:
{"CancelReturnCode":0,"Can celReturnD ata":"VPS- 50026","Re ferenceCod e":"991770 ","Jcode": "123456"," TimeStamp" :"13.01.20 20 15:17:37"}
How can I get the result of the Jcode? thank you
I use PHP and get the data like below.
$obj = json_decode($server_output
echo $output= $obj->result;
//the out put is:
{"CancelReturnCode":0,"Can
How can I get the result of the Jcode? thank you
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Where does $server_output come from?
As Chris says it looks like your JSON return is in turn json_encoded in which case a double decode will solve the problem but I am thinking we should find out why $server_output is double encoded. Double decoding could be just painting over code smell.
As Chris says it looks like your JSON return is in turn json_encoded in which case a double decode will solve the problem but I am thinking we should find out why $server_output is double encoded. Double decoding could be just painting over code smell.
or maybe this is actually an object which gets casted to text in that way ? that is what i assumed.
if @julian is right, you would decode with
json_decode(json_decode($s erver_outp ut)->resul t)->Jcode
... and double encoding is indeed weird
if @julian is right, you would decode with
json_decode(json_decode($s
... and double encoding is indeed weird
ASKER
thank you all,
using arrays is much easier : this can be achieved by passing TRUE as the second parameter to json_decode. then print_r($results) will make it totally obvious.