解析json的时候,如果有时间属性报错,需要注意的地方。

1.在解析传过来的json串时,如果带有时间参数,需要先将传入的时间参数先编译然后再传入。

注意:请求连接的属性要加入结束json类型的属性,加入接受时间注解@JsonFormat 保证解析时类型一致。

 创建一个解析json 的工具类JsonUtils

转换的类型

将其解析

需要解析的json 试例

lectuerColumnContent: {"img_url":"/0000/0034/img/201811/29/16/1839/5f7318ed-8113-473c-8168-45015e2c66ee.jpg","domain_name":"rr","description":"rr","experienceAchievementList":[{"start_time":"1521590400000","end_time":"1542758400000","title":"xxx","content":"rer","object_type":"J"},{"start_time":"1542672000000","title":"er","content":"er","object_type":"C"}],"real_name":"xxx","national_id":"422122199409263555","front_photo":"/0000/0034/img/201811/29/16/1635/1db093fe-dc40-42c0-b4e3-c1f2986be48f.jpg","back_photo":"/0000/0034/img/201811/29/16/1644/ab49dacc-ab51-4009-bcca-f9d63881ce1a.jpg","teacher_certification":"/0000/0034/img/201811/29/16/1642/5cf7a27e-6a4f-4229-9037-c45fc602ee10.jpg","email":"[email protected]","commitment":"/0000/0034/img/201811/29/16/1652/19d1fb50-9b8b-4a5e-b03d-850874e2a98a.jpg"}
 

分析:报错的原因,可能是在日期转化的时候格式不统一,导致解析的时候失败

猜你喜欢

转载自blog.csdn.net/qq_35414180/article/details/84763898
今日推荐