【发布时间】:2014-02-27 15:30:36
【问题描述】:
这是Removing linebreak from php json output 的后续问题。我不知道是什么造成了这个问题,但我不知何故摆脱了value <br ...JSONException。
问题
当我使用时
String url = "http://192.168.32.1/Aafois/notice.php?isBatch=2010&section1='IT'";
我得到了我想要的,即将 JSON 解析到我的 android 应用程序。但是当我使用时
String URL="http://192.168.32.1/Aafois/notice.php?isBatch="+isbatch+"§ion1="+"'"+section1+"'";
我得到Value of java.lang.string can't be converted to JSONArray...JSONException。所以很明显,上一行肯定有问题。isbatch 是一个整数变量,secton1 是一个字符串变量,即URL encoded to utf-8。
附言
我需要single quote ' 在变量section1 之前和之后,就像网址一样
http://192.168.32.1/Aafois/notice.php?isBatch=2010&section1='IT'。
【问题讨论】:
-
你能在第二种情况下打印
URL的结果值吗? -
你的简单问题解决了我的问题。我检查了这些变量,它们返回 null。修改了需要的内容。按预期工作。谢谢。