JAXB Marshalling with null fields

后端 未结 5 1942
挽巷
挽巷 2020-12-05 04:19

This is a pretty simple request, but I just didn\'t find a way to do it.

I\'m basically trying to set up a role in JAXB which says that whenever an null field is enc

5条回答
  •  臣服心动
    2020-12-05 04:55

    As indicated in the other answer is invalid since it is not a valid date. I had a similar issue where I wanted to handle (same as ) specially. Since you cannot use null, you can use the default value mechanism in JAXB. The following will default the value if none is specified. You can through code detect this special date and handle this exception case.

    @XmlElement(defaultValue="1970-01-01T00:00:00.0-00:00")
    

    So it is possible to detected and empty date value but you just cannot use null to do it.

提交回复
热议问题