【问题标题】:Android volley parse error, Value <html> of type java.lang.String cannot be converted to JSONArrayAndroid volley 解析错误,java.lang.String 类型的 Value <html> 无法转换为 JSONArray
【发布时间】:2016-04-05 08:23:47
【问题描述】:

我试图从我的database 商店的纬度和经度中获取,但是当我尝试在我的 Android 应用上获取 JSON response 时,我得到了 error:

com.android.volley.ParseError: org.json.JSONException: Value <html> of type java.lang.String cannot be converted to JSONArray

这是我的 PHP 文件中的 JSON:http://comparateur.16mb.com/ShopGet.php

    [{"id":"1","nom":"Leclerc LE KREMLIN ","marque":"Leclerc","adressemag":"106 Avenue DE FONTAINEBLEAU 94276 LE KREMLIN BICETRE CEDEX ","latitude":"48.809081","longitude":"2.362206","lundi":"8h30 - 21h","mardi":"8h30 - 21h","mercredi":"8h30 - 21h","jeudi":"8h30 - 21h","vendredi":"8h30 - 21h","samedi":"8h30 - 21h","dimanche":"8h30 - 13h"},{"id":"2","nom":"Leclerc PANTIN","marque":"Leclerc","adressemag":"51 Avenue JEAN LOLIVE BP 64 ZAC ILOT 93503 PANTIN CEDEX ","latitude":"48.891099","longitude":"2.401926","lundi":"9h - 20h30","mardi":"9h - 20h30","mercredi":"9h - 20h30","jeudi":"9h - 20h30","vendredi":"9h - 20h30","samedi":"9h - 20h30","dimanche":"Ferme"}]

【问题讨论】:

  • 看来问题与您的服务器响应有关。您使用字符串而不是 json 响应。我建议将 html 标头更改为 text/json 并避免在响应开头出现奇怪的空格。

标签: php android json


【解决方案1】:

是的,您必须在 android 端的 url 末尾添加“.php”或在服务器端配置 htaccess。

对于 htaccess: Redirect .php urls to urls without extension

【讨论】:

    【解决方案2】:

    你的网址有误,请在网址中添加 .php。

    您使用的是http://comparateur.16mb.com/ShopGet,但它应该是http://comparateur.16mb.com/ShopGet.php

    【讨论】:

      猜你喜欢
      • 2013-04-03
      • 1970-01-01
      • 1970-01-01
      • 2018-01-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-21
      相关资源
      最近更新 更多