com.alibaba.fastjson.JSONException: syntax error, expect {, actual [, pos 0

本文涉及的产品
全局流量管理 GTM,标准版 1个月
公共DNS(含HTTPDNS解析),每月1000万次HTTP解析
云解析 DNS,旗舰版 1个月
简介:         在使用fastjson解析的时候遇到该错误,网上查找了半天,找到位大神的帖子是说解析的实体A中有实体B,在该条json中A实体只有一个,但B实体却有多个,导致解析出错,解决办法是在A实体中定义B实体时,定义为List,这个是大神当时遇到的错误。

        在使用fastjson解析的时候遇到该错误,网上查找了半天,找到位大神的帖子是说解析的实体A中有实体B,在该条json中A实体只有一个,但B实体却有多个,导致解析出错,解决办法是在A实体中定义B实体时,定义为List<B>,这个是大神当时遇到的错误。我的错误不在于此。

我的错误是由于在封装json时封装的实体时List类型的,但解析的时候默认解析为一个实体,所以就出现了以上的错误

解析时的代码Moyiol_order mOrder=JSON.parseObject(ordersinfo, Moyiol_order.class);

封装时的代码List<Moyiol_order> result;

JSON.toJSONString(result);

只要在封装的时候将result取出要用的实体封装就可以了,如果需要封装多个实体,可以借鉴大神的思想自己寻找一下方法。

http://blog.csdn.net/jadyer/article/details/24395015

目录
相关文章
|
5月前
Caused by: org.apache.ibatis.type.TypeException: Could not resolve type alias ‘order‘. Caus
Caused by: org.apache.ibatis.type.TypeException: Could not resolve type alias ‘order‘. Caus
90 0
|
4月前
|
XML Java 数据库连接
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):XXXXX
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):XXXXX
|
5月前
|
XML Java 数据库连接
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.example.forum.d
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.example.forum.d
56 1
|
5月前
|
索引
Elasticsearch exception [type=illegal_argument_exception, reason=index [.1] is the write index for data stream [slowlog] and cannot be deleted]
在 Elasticsearch 中,你尝试删除的索引是一个数据流(data stream)的一部分,而且是数据流的写入索引(write index),因此无法直接删除它。为了解决这个问题,你可以按照以下步骤进行操作:
239 0
|
5月前
|
Java
org.apache.jasper.JasperException...(line: 15, column: 16) quote symbol expected和处理办法
org.apache.jasper.JasperException...(line: 15, column: 16) quote symbol expected和处理办法
|
数据库
解决numpy.core._exceptions.UFuncTypeError: ufunc ‘add‘ did not contain a loop with signature matching
解决numpy.core._exceptions.UFuncTypeError: ufunc ‘add‘ did not contain a loop with signature matching
1046 0
解决numpy.core._exceptions.UFuncTypeError: ufunc ‘add‘ did not contain a loop with signature matching
|
XML Java 数据库连接
解决org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)问题
解决org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)问题
10599 2
解决org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)问题
|
XML Java 数据库连接
【异常解决】解决org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)问题
【异常解决】解决org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)问题
209 0
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
117 0
|
XML SQL Java
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.rg.eduservice..
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.rg.eduservice..
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.rg.eduservice..