【发布时间】:2011-08-31 09:19:52
【问题描述】:
我正在尝试在我的 android 应用程序中进行 Json 解析,链接是 https://www.buzzador.com/apps/present_software/webservice/index.php?op=ProductQ&campaign_id=607&userid=10776
当我将它放入 Json 对象时,它会给我带来错误 错误是: 08-31 14:40:52.281: WARN/System.err(416): org.json.JSONException: java.lang.String 类型的值不能转换为 JSONObject
public static String getmyproductquestiondetails(String userid,
String campaignid) {// https://www.buzzador.com/apps/present_software/webservice/index.php?op=EducationResult&userid=1&questionid=1,2,3&answergivenbyuser=1,1,0
String data = null;
try {
URL url = new URL(
"http://dignizant.com/buzz/webservice/index.php?op=getProductQuestion&userid="
+ userid + "&campaign_id=" + campaignid);
if (url.getProtocol().toLowerCase().equals("https")) {
trustAllHosts();
HttpsURLConnection https = (HttpsURLConnection) url
.openConnection();
https.setHostnameVerifier(DO_NOT_VERIFY);
http = https;
} else {
http = (HttpURLConnection) url.openConnection();
}
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Utils utils = new Utils();
try {
data = utils.convertStreamToString(http.getInputStream());
System.out.println("getproduct details response :: " + data);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
data = e.toString();
}
return data;
}
try {
JSONObject jo = new JSONObject(response);
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
【问题讨论】:
-
请发布您正在使用的代码。
-
如果您可以发布代码,您的解析器就会崩溃。这将非常有帮助。
-
发布的示例代码不使用任何与 JSON 相关的内容。可能是您发布了错误的部分?
-
@Robert 现在我发布了 json 代码