JSONException:java.lang.String cannot be converted to JSONObject解决办法
来源:互联网 发布:mac打不开dmg文件 编辑:程序博客网 时间:2024/06/08 00:53
在用org.json.JSONObject 解析从网络获取的json数据时,遇到JSONException: java.lang.String cannot be converted to JSONObject,打印字符串,查看json字符串没有问题,研究了好长时间,终于找到问题,造成问题的原因是在编写json文件的时候,采用utf-8编码,utf8有个BOM格式,去掉这个格式就ok了。如何去掉呢?
如图:
另外还有一种办法,就是在java代码中去除BOM头:
public static String JSONTokener(String in) { // consume an optional byte order mark (BOM) if it exists if (in != null && in.startsWith("\ufeff")) { in = in.substring(1); } return in;}
- JSONException:java.lang.String cannot be converted to JSONObject解决办法
- JSONException:java.lang.String cannot be converted to JSONObject解决办法
- JSONException: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 JSONObject
- org.json.JSONException: Value of type java.lang.String cannot be converted to JSONObject
- org.json.JSONException: Value of type java.lang.String cannot be converted to JSONObject
- org.json.JSONException: Value of type java.lang.String cannot be converted to JSONObject
- org.json.JSONException: Value of type java.lang.String cannot be converted to JSONObject
- org.json.JSONException: Value of type java.lang.String cannot be converted to JSONObject
- org.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
- org.json.JSONException: Value of type java.lang.String cannot be converted to JSONObject
- 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:
- org.json.JSONException: Value ok of type java.lang.String cannot be converted to JSONObject: [Caugh
- java.lang.String cannot be converted to JSONObject
- Json解析异常处理方式(JSONException: Value of type java.lang.String cannot be converted to JSONObject)
- Spirng 入门 经典实例 详解~~
- jquery.ajax与nvelocity应用
- 核多不一定强,双核A9强过四核A7?
- hibernate语句日志实现
- vbscript抓取图片到本地
- JSONException:java.lang.String cannot be converted to JSONObject解决办法
- Eclipse中使用Microsoft Team Foundation Server来管理源代码
- open(/dev/ietctl, O_RDWR) 参数含义
- JPA注解实现
- springMVC 拦截器session控制
- maven配置hibernate
- 或许是单选的飞鸽传书
- post 方式传递汉字乱码解决
- drupal安装