2.8.1 can't serialize and deserialize date null (2.8.0 works fine)
See original GitHub issueW/System.err: com.google.gson.JsonParseException: The date should be a string value
W/System.err: at com.google.gson.DefaultDateTypeAdapter.read(DefaultDateTypeAdapter.java:96)
W/System.err: at com.google.gson.DefaultDateTypeAdapter.read(DefaultDateTypeAdapter.java:40)
W/System.err: at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:129)
W/System.err: at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:220)
W/System.err: at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:41)
W/System.err: at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:82)
W/System.err: at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:61)
this will trows JsonParseException
if (in.peek() != JsonToken.STRING) {
throw new JsonParseException("The date should be a string value");
}
this is my conf
new GsonBuilder().serializeNulls().setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS").create()
Issue Analytics
- State:
- Created 6 years ago
- Reactions:17
- Comments:8
Top Results From Across the Web
How do you specify default values for Jackson deserialization
You can define a custom getter property where setting your default value in case of null . public Integer getAge() { if (age...
Read more >Gson (Gson 2.8.0 API) - Javadoc.io
Moreover, if a field is not null, but its generated JSON is empty, the field is kept. You can configure Gson to serialize...
Read more >Custom Serializers in Apache Kafka - Baeldung
In this tutorial, we'll see how to implement Kafka default format converters and custom serializers for specific use cases.
Read more >Json.Net Error Deserializing DataTable from Json - MSDN
Can't figure out why this json text, which was serialized by Json.Net, can't simply be ... It does not deserialize Null values properly....
Read more >JSON parse error: Cannot deserialize value of type `java.time ...
Your browser can't play this video. ... LocalDateTime` This is the JsonFormat pattern that you will most likely need: "yyyy-MM-dd'T'HH:mm:ss ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi,
This is my workaround for this bug, waiting for 2.8.2:
Hope it will help
BR
it worked for me @bmarty thank you