org.json.JSONException:org.json.JSONArray类型的Value []无法转换为JSONObject [英] org.json.JSONException: Value [] of type org.json.JSONArray cannot be converted to JSONObject

查看:362
本文介绍了org.json.JSONException:org.json.JSONArray类型的Value []无法转换为JSONObject的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个正在运行的应用程序,但是我的服务器有一个小问题,我还没有解决我的服务器问题,并且我的登录遇到此问题,错误来自身份验证方法.错误说jsonarray无法被转换为jsonobject我已经做了我的日志,我希望有人可以看看它,并告诉我的问题是什么.我认为我的问题是我无法访问我的数据库,但我不确定它是否问题或我的问题是我的json.i无法解决验证例如org.json.JSON.typeMismatch(JSON.java:111)"这样的问题的用户名和密码的方法,这是我的粘贴容器

i have a running app but i had a little problem with my sever,i have yet to solve my server problems and i'm encountering this problem with my log in the error comes from the authentication method.the error says jsonarray cannot be converted to jsonobject i've made a pastbin of my log and i was hoping someone can take a look at it and tell what my problem is.i think my problem is that i cant access my database but im not really sure if its the problem or my problem is my json.i cant hink of way to authenticate my username and password withour having problem like "at org.json.JSON.typeMismatch(JSON.java:111)" here is my paste bin http://pastebin.com/zgzbxcSV

推荐答案

您从服务器获取了一个(可能为空)json数组,并尝试将其转换为JsonObject.

you get from the server a (maybe empty) json array and you are try to convert it in a JsonObject.

代替

JSONObject obj = new JSONObject(string);

你应该做

JSONArray obj = new JSONArray(string);

这篇关于org.json.JSONException:org.json.JSONArray类型的Value []无法转换为JSONObject的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆