异常信息
Value of type java.lang.String cannot be converted to JSONObject
原因
json数据格式不正确,可使用在线验证工具进行验证
UTF-8 的BOM头导致。在 Android 2.2 至 2.3.3 中未作处理,Android 4.0 及以上已经在内部类中处理了。
// Android 4.0及以上
public JSONTokener(String in) {
// consume an optional byte order mark (BOM) if it exists
if (in != null && in.startsWith(“\ufeff”)) {
in = in.substring(1);
}
this.in = in;
}// Android 2.2至2.3.3
public JSONTokener(String in) {
this.in = in;
}