PHP Users,

I'm decoding some JSON data in PHP to convert it into an array.

However, it's not working, and json_last_error() is returning a value of "4", which I believe means "Malformed UTF-8 characters, possibly incorrectly encoded".

I try at every turn in every setting to ensure that all my code and connections are in UTF-8.

But how can I be sure it's valid UTF-8? I've tried using the PHP command utf8_encode() on the string, but that hasn't changed anything.

And can I trust the error message?

Any help or advice would be much appreciated.

By the way, here is the code I'm currently testing with. I'm just encoding and then decoding a string right in the PHP just to get it to work before I even try getting the data from anywhere else.

$myData ='{"display_name":"Test
Guy","email":"test...@testaddress.com","timeout":"1279145273"}';
$myArray1 = json_encode($myData);
$myArray2 = utf8_encode (stripslashes($myArray1));
$myArray = json_decode($myArray2, true);
$jsonerror = json_last_error();

--
Dave M G

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to