项目解析json数据时发现报
org.json.JSONException: Value of type java.lang.String cannot be converted to JSONObject 错误。
在看源码时发现原来android4.0的json包已经对这个问题做了处理。见代码:
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;
}
public JSONTokener(String in) {
this.in = in;
}
而2.2的代码:
问题很简单了在网络层将responseString过滤一下就ok。不明白就去看一下utf-8 bom头。