您好我是Android的新手,我正在开发一个应用程序,我将向服务器发送请求并获取json数据。问题是,当收到服务器的响应时,当我试图得到它时,我得到一个例外 java.lang.String无法转换为JSONobject
答案 0 :(得分:0)
您的服务器返回了错误的json数据。还应删除额外的"
。
它应该类似于
[{
"image": "http://eprintpost.com/images/savepreflab/uploadSave/69120e7d-31e0-46ac-bf07-e86778bc2866.jpg",
"productid": "255",
"oldprice": "250",
"city": "Pune",
"price": "200",
"labname": "Emotions",
"productname": "Sublimation Bag (6058)"
}, {
"image": "http://eprintpost.com/images/savepreflab/uploadSave/48e9420c-3bd2-4c89-91a3-0de3346c072f.jpg",
"productid": "481",
"oldprice": "1000",
"city": "Coimbatore",
"price": "500",
"labname": "savithri photo house",
"productname": "camera toploader 450AW Black"
}, {
"image": "http://eprintpost.com/images/savepreflab/uploadSave/741e6549-94be-439d-b823-0bd8b26bb0ce.jpg",
"productid": "556",
"oldprice": "1000",
"city": "Dharwad",
"price": "400",
"labname": "Foto Magic Studio And Lab",
"productname": "07.jpg"
}]
答案 1 :(得分:0)
你能把你所有的错误日志猫吗?究竟是什么引发了这个错误
type java.lang.String cannot be converted to JSONObject
您的错误是从String解析为JSONObject所以让我们专注于哪些行解析为JSONObject