I'm receiving a JSON response from a url which on decoding returns null while decoding it directly from the string it produces gives results.
String returned from the url:
{"status_code":0,"response":{"names":"Bon Charles"},"status_message":"Succeeded."}
Result from URL on decoding: NULL Result on taking the produced string and hard-coding it into a string:
object(stdClass)#19 (3) { ["status_code"]=> int(0) ["response"]=> object(stdClass)#20 (1) { ["names"]=> string(15) "Bon Charles" } ["status_message"]=> string(16) "Succeeded." }
Below is the function that calls the url for the response:
public function checkLoginStatus() {
$status = $this->postLoginsJSON();
$values = json_decode($status);
$json_string = '{"status_code":0,"response":{"names":"Bon Charles"},"status_message":"Login Succeeded."}';
$a = json_decode($json_string);
var_dump($values);//returns null
var_dump($a);//returns values
}
Kindly assist.