我有从我的web服务接收json的json。 这将是这个样子,无法解析json在android
{"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数组从客户端的Android应用程序,它说这样
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
荫使用AsyncHttpClient(循环J)来解析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");
...
抱歉,这是[this]的重复问题(http://stackoverflow.com/questions/15945394/android-value-of-type-java-lang-string-cannot-be-converted-to-jsonarray) – noushad
为什么你想将json再次转换为字符串吗?你为什么不直接解析它? – SripadRaj
我在那里找到答案... – noushad