org.json.JSONException: Value of type java.lang.String cannot be converted to JSON
来源:互联网 发布:淘宝双十一的来源 编辑:程序博客网 时间:2024/05/16 02:13
在用org.json.JSONObject 解析从网络获取的json数据时,遇到JSONException: java.lang.String cannot be converted to JSONObject,
造成问题的原因是在编写json文件的时候,采用utf-8编码,utf8有个BOM格式,去掉这个格式就ok了
1.json文档要进行设置如下:
2.另外还有一种办法,就是在java代码中去除BOM头:
[java]
public static String JSONTokener(String str_json) {
// consume an optional byte order mark (BOM) if it exists
if (str_json != null && str_json.startsWith("\ufeff")) {
istr_json = str_json.substring(1);
}
return str_json;
}
0 0
- org.json.JSONException: Value of type java.lang.String cannot be converted to JSON
- org.json.JSONException: Value of type java.lang.String cannot be converted to JSON
- 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 JSONArra
- 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
- 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
- Json解析异常处理方式(JSONException: Value of type java.lang.String cannot be converted to JSONObject)
- org.json.JSONException: Value java.net.UnknownHostException of type java.lang.String cannot be conv
- JSONException: Value of type java.lang.String cannot be converted to JSONObject
- Value of type java.lang.String cannot be converted to JSONObject
- 百度地图JS--2
- jm8.6之参考帧管理
- tablefunc 行转列
- recovery PITR 即时恢复
- OCP 1Z0 051 145
- org.json.JSONException: Value of type java.lang.String cannot be converted to JSON
- hbase 表的备份
- Uni2d插件属性介绍
- 竖式问题
- iPad国内降价!在内地开启教育优惠
- 取 <td>里文本
- $(document).ready() 与 windows.onload的区别
- 用互联网创新基因做彩票
- 个人对nandflash驱动的总结(ok6410版)