Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

delete "return null",delivery deserializer to handle #980

Closed
ihrthk opened this issue Dec 19, 2016 · 1 comment
Closed

delete "return null",delivery deserializer to handle #980

ihrthk opened this issue Dec 19, 2016 · 1 comment

Comments

@ihrthk
Copy link

ihrthk commented Dec 19, 2016

TreeTypeAdapter.java
/**
@OverRide public T read(JsonReader in) throws IOException {
if (deserializer == null) {
return delegate().read(in);
}
JsonElement value = Streams.parse(in);
if (value.isJsonNull()) {
return null;
}
return deserializer.deserialize(value, typeToken.getType(), context);
}
**/

@Marcono1234
Copy link
Collaborator

The documentation for the GsonBuilder.registerTypeAdapter method has been adjusted by #1704 and the incorrect behavior when used with @JsonAdapter has been fixed by #1555. I am therefore closing this issue here (especially since it was not mentioned for which use case this behavior caused issues). #852 is still open, and maybe it can also be considered to add new GsonBuilder methods which allow registering JsonSerializer or JsonDeserializer without making them null-safe. For now the workaround is to use TypeAdapter or TypeAdapterFactory instead, if possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants