2012-03-07 54 views
0

这是Eclipse代码:警告在LongCat:JSONException

JSONObject j = new JSONObject(getRequest(myUrl)); 
JSONArray jArray = j.getJSONArray("data"); 

for (int i = 0; i < jArray.length(); i++) { 
    sret += jArray.getJSONObject(i).getString("NO_CUST").toString(); 
} 

这是PHP代码:

$result = mssql_query($query, $conn) or die('Errorquery: '.$query); 

$rows = array(); 
while ($r = mssql_fetch_assoc($result)) { 
    $rows[] = $r; 
} 
$data = "{data:".json_encode($rows)."}"; 
echo $data; 

的logcat:

03-07 16:05:58.504: W/System.err(821): org.json.JSONException: Value <br of type java.lang.String cannot be converted to JSONObject 

为什么?

+0

把你的全logcat的,你可以把网址? – 2012-03-07 09:53:06

+0

php代码的最后一行是echo $ data。你可以请添加PHP日志?我的意思是数据的打印值。 – Shaiful 2012-03-07 09:58:34

+0

@shaiful: 请编写代码... – 2012-03-08 01:57:20

回答

0

而不是

$data = "{data:".json_encode($rows)."}"; 
echo $data; 

使用

print(json_encode($data)); 
+0

我已经改变了代码,但仍然发现在logcat中相同的警告 – 2012-03-08 02:03:22