下面是代码:                
                String uriApi = context.getString(R.string.server_api_monitorData);
/* 创建连接 */
HttpPost request = new HttpPost(uriApi);
/* 创建参数列表 */
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("itemId", itemId));
params.add(new BasicNameValuePair("stattime", stattime));
params.add(new BasicNameValuePair("statTimeType", statTimeType));
JSONArray array = new JSONArray(); try {
request.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));
HttpResponse httpResponse = new DefaultHttpClient()
.execute(request); if (httpResponse.getStatusLine().getStatusCode() == 200) {
/* 取出响应字符串 */
String result = EntityUtils.toString(httpResponse.getEntity()); /* 将服务器返回的json数据转换为JsonOjbect */
JSONObject jsonObject = new JSONObject(result); /* 获取data下面的JSONArray */
array = new JSONArray(jsonObject.optString("data"));
array = getMonitorVSection(array, vsjArray);
// httpclient = new TimeOutSetClient();
// httpclient.setConnectionTimeOut(15);
} else {
Log.e("analyzeJsonService", httpResponse.getStatusLine()
.toString());
}
} catch (UnsupportedEncodingException e) {
Log.e("analyzeJsonService:", e.getMessage());
} catch (ClientProtocolException e) {
Log.e("analyzeJsonService:", e.getMessage());
} catch (IOException e) {
Log.e("analyzeJsonService:", e.getMessage());
} catch (JSONException e) {
Log.e("analyzeJsonService:", e.getMessage());
}
在JSONObject jsonObject = new JSONObject(result);时就解析报错了,在模拟器上可以解析成功,但是连接手机调试就报错,大家帮帮啊

解决方案 »

  1.   

    固件版本问题,说说你的环境。报什么错误,logcat贴下
      

  2.   

    报错信息:
    Unterminated object at character 145 of {'data':[{'RiverDataID':51,'AreaID':'445200','AreaName':'???é?????','SectionCode':'GD080000000101','SectionName':'???è????????','BusinessID':1,'StatTime':new Date(1199116800000),'StatTimeType':1,'LevelID':4,'LevelName':'???','OverItem':'???è§??°§','MainItem':'???è§??°§?????????é???°§é?????pH??????é??é?°é??????????°????°¨?°????????????????é???°§é???????????é??????±?????°???????','Isok':false,'CtrlLevel':2,'Standard':'??°è?¨?°???????è?¨é????????GB 3838???2002','WQAimName':'Zxh.Meq.Infrastructure.StandardLabel','MonAreaIDs':'445200','DutyAreaIDs':'445200','MonAreaNames':'???é?????','DutyAreaNames':'???é?????'},{'RiverDataID':114,'AreaID':'445200','AreaName':'???é?????','SectionCode':'GD080000000102','SectionName':'??????','BusinessID':1,'StatTime':new Date(1199116800000),'StatTimeType':1,'LevelID':6,'LevelName':'?????¤','OverItem':'??????é???°§é?????????°????????¤§è??è????¤','MainItem':'????°????????¤§è??è????¤?????????é???°§é?????é??é?°é??????????°??????????±?????°???????????????·????°¨?°?','Isok':false,'CtrlLevel':2,'Standard':'??°è?¨?°???????è?¨é????????GB 3838???2002','WQAimName':'Zxh.Meq.Infrastructure.StandardLabel','MonAreaIDs':'440500','DutyAreaIDs':'440500','MonAreaNames':'?±??¤????','DutyAreaNames':'?±??¤????'},
    虚拟器环境:AVD使用的是SDK Google APIs(API Level是7),手机的系统是android2.2的