org.json.JSONException: Value of type java.lang.String cannot be converted to JSONObject
来源:互联网 发布:复杂网络大会 编辑:程序博客网 时间:2024/04/28 04:47
重点:保存文件格式请选择:utf-8无BOM
在用org.json.JSONObject 解析从网络获取的json数据时,遇到JSONException: Java.lang.String cannot be converted to JSONObject,
造成问题的原因是在编写json文件的时候,采用utf-8编码,utf8有个BOM格式(json串头部发现字符:”\ufeff” )。去掉这个格式就ok了。
1.json文档要进行设置如下:
2.另外还有一种办法,就是在java代码中去除BOM头:
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; }
参考:org.json.JSONException: Value of type java.lang.String cannot be converted to JSON
项目中遇到:
友盟遇到这个错误:
分享报错jsonException
确认分享操作是否能正常执行即可,这些报错都是内部调试日志,不影响正常分享流程。
阅读全文
0 0
- 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 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
- 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 JSONArra
- 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)
- Value of type java.lang.String cannot be converted to JSONObject
- Value of type java.lang.String cannot be converted to JSONObject
- windows 消息代码大全
- 面试总结——Java高级工程师
- LeetCode 7. Reverse Integer C++--带正负号数字反转
- 深度学习框架caffe源码学习(一) — caffe.proto
- Oracle 数据库、实例、服务名、SID
- org.json.JSONException: Value of type java.lang.String cannot be converted to JSONObject
- JS学习-filter()和sort()
- bzoj 2987: Earthquake 类欧几里德算法
- MySQL知识点汇总
- Conflict with dependency的解决方法
- Android 各个版本WebView
- SpringMVC+MyBatis 事务管理二
- HDU
- 线程池原理