com.android.volley.ParseError: org.json.JSONException [英] com.android.volley.ParseError: org.json.JSONException
本文介绍了com.android.volley.ParseError: org.json.JSONException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我从 volley 库中得到这个错误
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
如何以字符串形式接收结果,然后使用 jackson 处理它?</p>
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屋!
查看全文