Reputation: 457
I am trying to decode json string containing Japanese words.I have tried
$rec_data= '{"id":"220011","name":"を送"}';
$data = json_decode(utf8_encode($rec_data),TRUE);
var_dump($data);
but it returning
array(2) { ["id"]=> string(6) "220011" ["name"]=> string(8) "ð" }
I want it to be
array(2) { ["id"]=> string(6) "220011" ["name"]=> string(8) "を送" }
how to resolve this?
Upvotes: 1
Views: 891
Reputation: 9583
You need to use JSON_UNESCAPED_UNICODE
when you encode your array to json
.
Online link for testing.
$array = array("id"=> "220011", "name" => "を送");
$rec_data = json_encode($array, JSON_UNESCAPED_UNICODE);
$data = json_decode($rec_data, TRUE);
var_dump($data);
Result:
array(2) { ["id"]=> string(6) "220011" ["name"]=> string(6) "を送" }
Upvotes: 2