简体   繁体   English

如何使用Android Volley导入json对象?

[英]How can i import json object using android volley?

I'm following this tutorial to import json data from online server. 我正在按照本教程从在线服务器导入json数据 fortunately that's work when i request as StringRequest , but unfortunately not working when request as JsonObjectRequest fail in volley exception : 幸运的是,当我作为StringRequest请求时,这是可行的,但是不幸的是,当作为JsonObjectRequest请求在排球异常中失败时,它不起作用:

08-27 18:14:24.586 32344-32344/com.mohamedslama.trydb E/TAG: com.android.volley.ParseError: org.json.JSONException: Value connected of type java.lang.String cannot be converted to JSONObject 08-27 18:14:24.586 32344-32344 / com.mohamedslama.trydb E / TAG:com.android.volley.ParseError:org.json.JSONException:类型为java.lang.String的连接值无法转换为JSONObject

and here is the php file . 这是php file

so any suggestion please, Thanks in advance. 因此,请提出任何建议,谢谢。

Remove echo "connected" from line 8 in your php code. 从PHP代码的第8行中删除echo "connected" It destroy the json structure 它破坏了json结构

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM