You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There's a pattern for json serialization through Jackson that Immutables is using that works in Jackson but it's not currently supported by gwt-jackson.
The Immutables pattern looks like this. You define an abstract class/interface, annotate it with @Immutable, and Immutables will generate an immutable implementation of the abstract class/interface with Jackson serialization and deserialization support (in case Jackson is found on the classpath).
From an interface similar to this:
@JsonTypeInfo( use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY)
@JsonSerializepublicinterfacePerson {
StringgetName();
ImmutablePersonwithName(Stringname);
}
it generates a class similar to this (ommitting the things irrelevant to this issue):
Note the @JsonCreator pattern that it's using on the fromJson method. It basically tells Jackson, that whenever the ImmutablePerson class is encountered when deserializing, it should use that factory method by deserializing the current JSON object under deserialization and calling the factory method with the delegate deserialized object as the argument.
Note that the json type that is used as a delegate here is marked with @JsonTypeInfo(use=Id.NONE), and this is actually important, as only types declared like this are usable for @JsonCreator(mode = Mode.DELEGATING) factory method. gwt-jackson doesn't support this use case, it will fail on
There's a pattern for json serialization through Jackson that Immutables is using that works in Jackson but it's not currently supported by gwt-jackson.
The Immutables pattern looks like this. You define an abstract class/interface, annotate it with
@Immutable
, and Immutables will generate an immutable implementation of the abstract class/interface with Jackson serialization and deserialization support (in case Jackson is found on the classpath).From an interface similar to this:
it generates a class similar to this (ommitting the things irrelevant to this issue):
Note the
@JsonCreator
pattern that it's using on thefromJson
method. It basically tells Jackson, that whenever theImmutablePerson
class is encountered when deserializing, it should use that factory method by deserializing the current JSON object under deserialization and calling the factory method with the delegate deserialized object as the argument.Note that the json type that is used as a delegate here is marked with
@JsonTypeInfo(use=Id.NONE)
, and this is actually important, as only types declared like this are usable for@JsonCreator(mode = Mode.DELEGATING)
factory method. gwt-jackson doesn't support this use case, it will fail ongwt-jackson/gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/rebind/bean/BeanProcessor.java
Lines 459 to 461 in 4ba7f99
I will provide a PR with a JUnit test for this issue.
The text was updated successfully, but these errors were encountered: