{ "a": { "date": 6, "day": 2, "hours": 18, "minutes": 37, "month": 7, "seconds": 1, "time": 1565087821607, "timezoneOffset": -480, "year": 119 } }
这个时间串儿不能直接转成date对象吗?那怎么转,报错如下
Exception in thread "main" com.alibaba.fastjson.JSONException: syntax error, expect }, actual , at com.alibaba.fastjson.parser.DefaultJSONParser.accept(DefaultJSONParser.java:1496) at com.alibaba.fastjson.parser.deserializer.AbstractDateDeserializer.deserialze(AbstractDateDeserializer.java:154) at com.alibaba.fastjson.parser.deserializer.AbstractDateDeserializer.deserialze(AbstractDateDeserializer.java:15) at com.alibaba.fastjson.parser.deserializer.DefaultFieldDeserializer.parseField(DefaultFieldDeserializer.java:85) at com.alibaba.fastjson.parser.deserializer.JavaBeanDeserializer.parseField(JavaBeanDeserializer.java:1224) at com.alibaba.fastjson.parser.deserializer.JavaBeanDeserializer.deserialze(JavaBeanDeserializer.java:850) at com.alibaba.fastjson.parser.deserializer.JavaBeanDeserializer.parseRest(JavaBeanDeserializer.java:1537) at com.alibaba.fastjson.parser.deserializer.FastjsonASMDeserializer_1_A.deserialze(Unknown Source) at com.alibaba.fastjson.parser.deserializer.JavaBeanDeserializer.deserialze(JavaBeanDeserializer.java:284) at com.alibaba.fastjson.parser.DefaultJSONParser.parseObject(DefaultJSONParser.java:689) at com.alibaba.fastjson.JSON.parseObject(JSON.java:378) at com.alibaba.fastjson.JSON.parseObject(JSON.java:282) at com.alibaba.fastjson.JSON.parseObject(JSON.java:555)
Q
[alibaba/fastjson]用json-lib转换的json串儿(带时间),用fastjson转对象报错
4
A
回答
6
你的Java bean的定义是怎样的,给个例子吧
1
@jiacye13 json-lib转换的json的时候,需要格式化一下日期。 可以参考https://blog.csdn.net/huangxw000/article/details/7106501
8
可以参考这个用例里的方式:https://github.com/alibaba/fastjson/pull/2767