Skip to content
This repository was archived by the owner on Oct 23, 2024. It is now read-only.
This repository was archived by the owner on Oct 23, 2024. It is now read-only.

toJavaObject 不会触发JSONField #1727

@aqqwiyth

Description

@aqqwiyth
        String jsonString = "{\"gmtCreate\":\"20180131214157805-0800\"}";
        JSONObject.parseObject(jsonString, XX.class); //正常解析
        JSONObject.toJavaObject(JSON.parseObject(jsonString), XX.class); 



@JSONField(format="yyyyMMddHHmmssSSSZ")
private Date gmtCreate;

Caused by: com.alibaba.fastjson.JSONException: can not cast to Date, value : 20180131214157805-0800
at com.alibaba.fastjson.util.TypeUtils.castToDate(TypeUtils.java:326)
at com.alibaba.fastjson.util.TypeUtils.cast(TypeUtils.java:746)
at com.alibaba.fastjson.util.TypeUtils.cast(TypeUtils.java:846)
at com.alibaba.fastjson.parser.deserializer.JavaBeanDeserializer.createInstance(JavaBeanDeserializer.java:1159)
at com.alibaba.fastjson.util.TypeUtils.castToJavaBean(TypeUtils.java:1034)
... 8 more

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions