iex
01/21/2020, 3:39 PMregisterTypeAdapter(Date::class.java, DateDeserializer())
So when the object has a non optional Date
, it's clear that I should throw an exception if it gets an empty string. But when Date
is optional, I'd like to map the empty string to null
, i.e. the date will just be assigned null
. Not sure how to do that. It relates with lang, in that the deserializer is defined like this:
`JsonDeserializer<Date>`but I need it to work with Date?
basically.
I can of course create a getter in my object that deserializes the date if present, but I'd like to do this directly with the parser, not "outside".ribesg
01/21/2020, 3:44 PM""
and null
are not the same thingiex
01/21/2020, 3:45 PMiex
01/21/2020, 3:45 PM""
as null
because the api is defective and it can't be fixediex
01/21/2020, 3:51 PMiex
01/21/2020, 3:55 PMJsonDeserializer<Date?>
(and returning null
if it's an empty string)iex
01/21/2020, 3:57 PMnull
iex
01/21/2020, 3:58 PMDate?
.diesieben07
01/21/2020, 4:04 PMDate?
field).iex
01/21/2020, 4:30 PMString?
in my object and adding a computed variable to generate the Date?
iex
01/21/2020, 4:31 PMobject