JSONException:java.lang.String cannot be converted to JSONObject
2014-03-03 17:21
471 查看
在用org.json.JSONObject 解析从网络获取的json数据时,遇到JSONException: java.lang.String cannot be converted to JSONObject,打印字符串,查看json字符串没有问题,研究了好长时间,终于找到问题,造成问题的原因是在编写json文件的时候,采用utf-8编码,utf8有个BOM格式,去掉这个格式就ok了。如何去掉呢?如图:
public static String JSONTokener(String in) {// consume an optional byte order mark (BOM) if it existsif (in != null && in.startsWith("\ufeff")) {in = in.substring(1);}return in;}
相关文章推荐
- Json解析异常处理方式(JSONException: Value of type java.lang.String cannot be converted to JSONObject)
- Json解析异常处理方式(JSONException: Value of type java.lang.String cannot be converted to JSONObject)
- JSONException: Value of type java.lang.String cannot be converted to JSONObject
- JSONException: java.lang.String cannot be converted to JSONObject
- org.json.JSONException: Value ok of type java.lang.String cannot be converted to JSONObject:
- JSONException: Value of type java.lang.String cannot be converted to JSONObject
- new JSONObject(str)无法解析 报错:org.json.JSONException: Value of type java.lang.String cannot be converted to JSONObject
- org.json.JSONException: Value ok of type java.lang.String cannot be converted to JSONObject: [Caugh
- Json解析异常处理方式(JSONException: Value of type java.lang.String cannot be converted to JSONObject)
- JSONException:java.lang.String cannot be converted to JSONObject解决办法
- org.json.JSONException: Value of type java.lang.String cannot be converted to JSON
- alue of type java.lang.String cannot be converted to JSONObject
- org.json.JSONException: Value of type java.lang.String cannot be converted to JSONArra
- Value of type java.lang.String cannot be converted to JSONObject 异常
- Value of type java.lang.String cannot be converted to JSONObject
- Value of type java.lang.String cannot be converted to JSONObject
- org.json.JSONException: Value of type java.lang.String cannot be converted to JSON
- java.lang.String cannot be converted to JSONObject
- org.json.JSONException: Value of type java.lang.String cannot be converted to JSONArra
- of type java.lang.String cannot be converted to JSONObject: Android