Reputation: 1574
I'm trying to convert a json string containing utf-8 symbols to a php array.
$jsonString = '{"loginid" : "90", "username" : "\U0437\U0430\U043c\U043a\U0435"}';
$array = json_decode($jsonString,true);
Unfortunately json_decode
returns null.
Where is my mistake?
Upvotes: 1
Views: 161
Reputation: 1044
Use \u
instead of \U
. Try this:
$jsonString = '{"loginid" : "90", "username" : "\u0437\u0430\u043c\u043a\u0435"}';
$array = json_decode($jsonString,true);
Upvotes: 1
Reputation: 3200
Try escaping your slashes.
<?php
$jsonString = '{"loginid" : "90", "username" : "\\\U0430"}';
$array = json_decode($jsonString, true);
print "<PRE><FONT COLOR=ORANGE>"; print_r($array); print "</FONT></PRE>";
Upvotes: 1