com.android.volley.ParseError:org.json.JSONException [英] com.android.volley.ParseError: org.json.JSONException
本文介绍了com.android.volley.ParseError:org.json.JSONException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我从排球库中得到了这个错误
I got this error from volley library
@Override
public void onErrorResponse(VolleyError error) {
error.printStackTrace();
}
错误
com.android.volley.ParseError: org.json.JSONException: Value [{"id":"admin","name":"Admin"}] of type org.json.JSONArray cannot be converted to JSONObject
我如何以字符串形式接收结果,然后使用杰克逊进行处理?
How can I receive the result as string and then I will process it using jackson ?
推荐答案
如果要以字符串形式接收结果,请不要使用JSONRequest.使用简单的Request类. 您的问题很简单,服务器正在返回仅包含一个元素的JSONArray. JSONArray不是JSONObject.这就是解析失败的原因.
If you want to receive the result as a string don't use the JSONRequest. Go with the simple Request class. Your problem is pretty simple the server is giving back a JSONArray with just one element inside. A JSONArray is not a JSONObject. That's why the parsing is failing.
这篇关于com.android.volley.ParseError:org.json.JSONException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文