I have a JSON string that contains Dal\u00e9
. When I use json_decode
on the JSON, it is converted to Dalé
, however the original string that the JSON is from is Dalé
. Why is this not converted properly?
I have found that "\u00E9"
is the C/C++/Java source code encoding for é
. However, to me this doesn't answer why this is going wrong.
Example of incorrect PHP output:
<?php
$opts = array('http'=>array('ignore_errors' => true));
$context = stream_context_create($opts);
$jsonurl = "http://api.kivaws.org/v1/loans/552804.json";
$json = file_get_contents($jsonurl, false, $context);
$json_output = array(json_decode($json));
$json_error = $json_output[0]->error;
$json_message = $json_error->message;
foreach ($json_output[0]->{'loans'} as $loan) {
echo 'Name: '.$loan->{'name'};
}
?>