nmorel / gwt-jackson

gwt-jackson is a JSON parser for GWT. It uses Jackson 2.x annotations to customize the serialization/deserialization process.
Apache License 2.0
111 stars 55 forks source link

Add suppor to @JsonDeserialize(as=MyImpl.class) #57

Closed lisboa closed 9 years ago

lisboa commented 9 years ago

Hello Nicolas, You can give a direction of how to include the annotation @JsonDeserialize(as=MyImpl.class) ?

@JsonTypeInfo has some limitations. One is the bi-directional link between interface and implementation. Besides, In some cases, the server and client should only share interfaces. For example, the server can be a heavy implementation of the interface while the client is a lightweight container for data.

Thanks, Fabio

nmorel commented 9 years ago

I will look at it next week, I won't have time this one, sorry :(

In the meantime, if your problem is to use a different implementation, you could use @JsonTypeInfo with Id.NAME and with mixin register a different implementation to the name in client and server.

Or use a completely different root POJO between client and server.

lisboa commented 9 years ago

Hi Nicolas, this is great. Thanks!

nmorel commented 9 years ago

With 2 month late, I finally look at it. as, keyAs and contentAs are supported on fields and methods (not class or constructor parameters). To use it, you have to add jackson-databind dependency in your GWT classpath (should already be the case if you are using the annotation).