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

本文涉及的产品
公共DNS(含HTTPDNS解析),每月1000万次HTTP解析
云解析 DNS,旗舰版 1个月
全局流量管理 GTM,标准版 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

目录
相关文章
|
2月前
|
Docker 容器
成功解决:Caused by: ParsingException[Failed to parse object: expecting token of type [START_OBJECT] but
这篇文章讨论了在使用Docker启动Elasticsearch容器时遇到的一个具体问题:由于配置文件`elasticsearch.yml`解析出错导致容器启动失败。文章提供了详细的排查过程,包括查看容器的日志信息、检查并修正配置文件中的错误(特别是空格问题),并最终成功重新启动了容器。
|
3月前
|
JSON Java 数据格式
JSON parse error: Unexpected character (‘t‘ (code 116)): was expecting double-quote to start field n
JSON parse error: Unexpected character (‘t‘ (code 116)): was expecting double-quote to start field n
|
5月前
|
应用服务中间件 Python 容器
ERROR [ntContainer#0-1] o.s.a.r.l.SimpleMessageListenerContainer 1917: Failed to check/redeclare aut
ERROR [ntContainer#0-1] o.s.a.r.l.SimpleMessageListenerContainer 1917: Failed to check/redeclare aut
175 0
|
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),因此无法直接删除它。为了解决这个问题,你可以按照以下步骤进行操作:
220 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和处理办法
org.activiti.engine.ActivitiException: Couldn't deserialize object in variable 'application'
org.activiti.engine.ActivitiException: Couldn't deserialize object in variable 'application'
|
数据库
解决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
1039 0
解决numpy.core._exceptions.UFuncTypeError: ufunc ‘add‘ did not contain a loop with signature matching
|
JSON 前端开发 数据格式
org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize instance of `object` out of START_ARRAY token
讲述如何处理 org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize instance of `object` out of START_ARRAY token的问题
 org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize instance of `object` out of START_ARRAY token
成功解决absl.flags._exceptions.UnrecognizedFlagError: Unknown command line flag 'data_format'
成功解决absl.flags._exceptions.UnrecognizedFlagError: Unknown command line flag 'data_format'
报错:pandas.errors.ParserError: Error tokenizing data. C error: Expected 1 fields in line 7, saw 2
报错:pandas.errors.ParserError: Error tokenizing data. C error: Expected 1 fields in line 7, saw 2
报错:pandas.errors.ParserError: Error tokenizing data. C error: Expected 1 fields in line 7, saw 2