我创建了一个php文件来生成JSON代码。
我的PHP代码是:
<?php
include ('config.php');
mysql_query('SET CHARACTER SET UTF8');
mysql_query("SET NAMES utf8; ");
$check = mysql_query("SELECT * FROM news WHERE 1");
while($row=mysql_fetch_assoc($check))
$output[]=$row;
$json_encode =json_encode($output);
$utf8_decode = utf8_decode($json_encode);
echo $json_encode;
mb_convert_encoding($json_encode, 'UTF-8');
$html_entity_decode = html_entity_decode($json_encode);
mysql_close();
?>
,输出在此链接中:here
但是,当我在此站点中检查JSON格式的验证时:here
它给了我以下错误:
The JSON input is NOT valid according to RFC 4627 (JSON specification). Unexpected token [{"news_id":"11","news_content":"\u0639\u0637\u0648\u0631 \u0628\u0623\u062e\u0641 \u0627\u0644\u0627\u062d\u062c\u0627\u0645 \u062a\u0635\u0644\u062d \u0644\u062c\u0645\u064a\u0639 \u062...
这会影响Java中的解析并给出以下异常:
Error parsing data org.json.JSONException: Value of type java.lang.String cannot be converted to JSONArray
如何解决这个问题?
提前致谢。