I have a json respond that I want to check and return values accordingly: the Json code is:
{
"success": "true",
"result": "ok"
}
And I need to check the success status and return an array to the controller accordingly.
I was trying to decode and ask questions on the value as follow:
$obj = json_decode($response,true);
if ($obj['success'] =='true')
return array(
'error' => 0,
'msg' => sprintf("successfully")
);
I am not sure what i am doing wrong since I can't get the 0 in the error on array returns.
There is another json code that I need to deal with and it is this:
Negative Response:
{
“success” : “false” ,
“error”:{
“code”:"MANDATORY_FIELDS_MISSING",
"message”: “Phone number is a mandatory field"
}
}
The same goes with this.
I would be happy if you couls assist me with gettin it to work properly. Thank you. Arye
"true", not the booleantrue?