我有從我的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