I have a C# client, its send a json to my php server.
There is the json string:
{"data":[{"name":"1"}]}
Its a valid json. When i try it in PHP Sandbox its works good
$ad = '{"data":[{"name":"1"}]}';
$contents = utf8_encode($ad );
$results = json_decode($contents);
var_dump($results->data);
But,when i try in laravel 5.1, its not work good.
$response = $connection -> getData();
// return $response; (Its equal : {"data":[{"name":"1"}]} )
$contents = utf8_encode($response);
$results = json_decode($contents);
dd($results->data); // Error Trying to get property of non-object
I hope someone can help me. Thanks!
var_dump($contents)AFTER you do the utf stuff, and thenecho json_last_error(); var_dump($results)after the decode attempt. see what really came out.$connectionvariable? Please post the entire code snippet including the part where you setup the connection. Just because you see the same output in the browser when you return the response, doesn't necessarily mean it's encoded properly.