json_encode utf8 - php

我把一些数据放到我的mysql数据库中,可以正常工作。
但是,当我使用json_encode获取数据时,我会像这样返回ist:

{"idpostdata":"49","artID":null,"timestamp":"06.11.2012 13:35","lat":"51.496911","lon":"7.4022327","cellID":null,"road":"Wittener Stra\u00dfe","suburb":"Eichlinghofen","city":"Dortmund","postdatacol":null,"state_district":"Regierungsbezirk Arnsberg","state":"North Rhine-Westphalia","country_code":"de"}

您看到"road":"Wittener Stra\u00dfe"不是正确的名称,它必须是WittenerStraße

我的代码:

<?php
$sql = mysql_query("SELECT * FROM postdata");

while ($ds = mysql_fetch_assoc($sql)) 
  $output[]=$ds;
echo "{uTraf:";
  print(json_encode($output));
echo  "}";
mysql_close($dz);
?>

怎么了?

参考方案

怎么了?

没有。 \uxxxx是JSON编码UTF-8字符的方式。

当您使用适当的JSON解码方法解码JSON时,它将再次正常。

PHP-MySQL结果转换为JSON - php

我试图了解如何将MySQL结果转换为JSON格式,以便以后可以在Javascript中使用此JSON来构建HTML表。但是我的代码只是产生大量的空值,我还不明白为什么。$result = mysqli_query($con, "SELECT * FROM Customers"); $test = json_encode($result);…

json_encode网址失败 - php

有人在this bug附近吗?echo json_encode(array('url'=>'/foo/bar')); {"url":"\/foo\/bar"} 我使用Zend_Json and Zend_Json_Expr以便我甚至可以在js对象中获取回调函数-但我无法获得…

json_encode的特定方式 - php

所以这是我的PHP<?php include 'connect.php'; $sql = "SELECT name from startup_schema"; $result = mysqli_query($mysqli, $sql) or die("Error in Selecting " …

PHP:将数组值加在一起 - php

我相信这比标题听起来要难一些,但我可能完全错了。我有一个像这样的数组:[["londrina",15],["cascavel",34],["londrina",23],['tiradentes',34],['tiradentes',21]] 我希望能够采用通用…

jQuery帮助获取JSON数据 - php

我在这里遇到麻烦,我的json数据输出如下:{"date":[{"day_w":"Tuesday","day_n":"28","month":"Dec"}],"subscriptions":[{�…