解析Json数据的时候抛出MalformedJsonException
来源:互联网 发布:手机表白神器软件 编辑:程序博客网 时间:2024/06/07 05:16
1, 网络请求到的数据格式如下
{"code":"4fabe0d0ce474d6c95888955eb5b43d6","rejectReason":"拒绝义工","orderNumber":"20161020015954","createdBy":"85cd8594e47b481caddaa718ebd47e81","shortOrderDate":"2016-10-20","courseCode":"70d60f50313740aea7cbde9c94c95169","orderStatus":2,"orderDate":1476899995000,"courseTitles":"102课程"}
2, 一开始直接用gson解析
<pre name="code" class="java">Gson gson = new Gson();
EnrollsDetailInVolunteer bookSelect = gson.fromJson(reader, EnrollsDetailInVolunteer.class);
就报了标题所示异常
解决:
方法一:
<pre name="code" class="java">Gson gson = new Gson();
data = data.substring(0, data.lastIndexOf("}") + 1);EnrollsDetailInVolunteer bookSelect = gson.fromJson(reader, EnrollsDetailInVolunteer.class);
方法二:
<span style="white-space:pre"></span>Gson gson = new Gson(); JsonReader reader = new JsonReader(new StringReader(data)); reader.setLenient(true); EnrollsDetailInVolunteer bookSelect = gson.fromJson(reader, EnrollsDetailInVolunteer.class);
1 0
- 解析Json数据的时候抛出MalformedJsonException
- retrofit gson 解析json数据失败问题“com.google.gson.stream.MalformedJsonException:”
- 在解析json数据判空的时候
- json 的数据解析
- JSON数据的解析
- JSon数据的解析
- JSON数据的解析
- JSon数据的解析
- json的数据解析
- Json数据的解析
- JSON数据的解析
- JSON数据的解析
- json数据的解析
- JSON数据的解析
- Json数据的解析
- Json数据的解析
- Json数据的解析
- JSON解析的时候遇到NSNull
- apache的虚拟域名rewrite配置以及.htaccess的使用。
- JQ选择的链式写法
- scrapy的应用
- 2016.10.20-日志
- 基于C#\WPF的UDP网口助手源码
- 解析Json数据的时候抛出MalformedJsonException
- 【多用户访问一个文件】文件锁
- r进行crt预估
- Hive参数
- typedef和#define的用法与区别
- 西南联训5[Source from NK] 题解&总结
- MVD微型机器视觉设备 (Micro Vision Device) ---- 源于OpenMV,超越OpenMV
- 串的堆分配的基本操作
- 大数据量Elastic数据迁移方法及注意事项