我有从我的Web服务接收json的json。会是这样的,
{"JSONDataResult":"[{"id":3,"e_code":123533,"type":"ab","description":"sick-leave","remarks":"test","req_date":"2016-07-01T12:22:34","date":"01/07/2016","response":null,"aproved_date_time":null,"status":"not seen"}]"}
从 JSON http://www.jsoneditoronline.org/验证它时,它说它只有一个对象。我什至无法从客户端安卓应用程序将其转换为 json 数组,它是这样说
的 org.json.JSONException: Value [{"id":3,"e_code":123533,"type":"ab","description":"sick-leave","remarks":"test","req_date":"2016-07-01T12:22:34","date":"01/07/2016","response":null,"aproved_date_time":null,"status":"not seen"}] at JSONDataResult of type java.lang.String cannot be converted to JSONArray
I正在使用AsyncHttpClient(loopj)来解析json
client.get("http://192.168.1.6/JSONService/RESTService.svc/json/dddd",new JsonHttpResponseHandler(){
@Override
public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
try {
String str=response.toString();
JSONObject jobj=new JSONObject(str);
jsonArray=jobj.getJSONArray("JSONDataResult");
...
你可以通过以下方式解析它:
假设您在下面的变量中得到响应,如 strData
strData = strData.replaceAll("\","");
JSONObject jsonObject = new JSONObject(strData);
JSONArray jsonArray = jsonObject.getJSONArray("JSONDataResult");