Giter Site home page Giter Site logo

nmorel / gwt-jackson Goto Github PK

View Code? Open in Web Editor NEW
111.0 20.0 53.0 2.17 MB

gwt-jackson is a JSON parser for GWT. It uses Jackson 2.x annotations to customize the serialization/deserialization process.

License: Apache License 2.0

Java 100.00%
gwt jackson json

gwt-jackson's Introduction

Hi there, Nicolas Morel here!

Twitter Follow

๐Ÿ‡ซ๐Ÿ‡ท France ๐Ÿฅ– / Brittany / Rennes

๐Ÿ‘ฑโ€โ™‚๏ธ Who am I

  • Senior Software Engineer @ Gladia
  • Used to be a Java developer (GWT / Spring / Hibernate)
  • Now a Javascript / Typescript developer
  • Trying to learn Rust
  • Worked for Klaxoon
  • Worked for Mille Volts
  • Worked for Capgemini

๐Ÿ“ข Talks

๐Ÿค Social Media / links

gwt-jackson's People

Contributors

amirtoole avatar batrashubham avatar bauna avatar crevete avatar dnouls avatar fr3driiik avatar freddyboucher avatar ge0ffrey avatar hoppermann avatar majcn avatar mkristian avatar nmorel avatar richturner avatar vai-frd avatar ww3456 avatar yissachar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gwt-jackson's Issues

Handle Void

Generator currently fails when it tries to parse Void type.

StackOverflowError during compilation

A stack overflow happens with parameterized classes that use themselves as a parameter, like:

interface IdentifiableEntity<T extends IdentifiableEntity<T>> {}

Found in issue #44.

make AbstractObjectMapper.getSerializer / getDeserializer public?

It would be nice if
com.github.nmorel.gwtjackson.client.AbstractObjectMapper
methods
protected JsonSerializer getSerializer()
and
protected JsonDeserializer getDeserializer()
were public. Then a custom serializer/deserializer could delegate object deserialization/serialization.

For example if we're deserializing a typed map (Map<String,Object>) where map key defines value type and the values are POJOs.

Or is there a better way to do it?

Ignore static fields

When looking for fields to serialize/deserialize, the generator does not ignore the static fields.

Support for Guava

Now that we can add custom serializer and deserializer, let's add an extension library for Guava

add support to @JsonIgnoreProperties

Hi, I would like to see the @JsonIgnoreProperties annotation added to the library.
Currently, any rest service which changes any property of a result breaks the call with a message like:
...
Caused by: com.github.nmorel.gwtjackson.client.exception.JsonDeserializationException: Unknown property 'the_new_property_field'

Thanks

Rewrite generators

Currently, generators are really hard to read and understand.
Writing code at hand and the lack of comments are the main issues.
The generated code is also hard to read because there are no import, I only use qualified class names.

javapoet could be a nice solution.

ropertyParser.extractFieldNameFromGetterSetterMethodName throw exception java.lang.StringIndexOutOfBoundsException: String index out of range: 4

Hi,

I have an exception during compilation: http://pastebin.com/b6Uf7EBt
I use: java 1.7, gwt 2.6.1 gwt-jackson 0.6.2.

The error is somewhere here:

public static interface ResponseMapper extends ObjectMapper<Response> { }
public static ResponseMapper MAPPER = GWT.create(ResponseMapper.class);

Response is an interface:

 */
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "@class")
@JsonSubTypes({@JsonSubTypes.Type(value = ErrorResponse.class), @JsonSubTypes.Type(value = MessageResponse.class)})
public interface Response {

}

And has 2 implementations. One of them is MessageResponse:

package org.csgid.ucl.common.shared;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;

public class MessageResponse extends Response {

    public MessageResponse() {
    }

    @JsonCreator
    public MessageResponse(@JsonProperty("message") String message, 
                           @JsonProperty("data") Serializable data) {
        this.message = message;
        this.data = data;
    }

    private String message;
    private Serializable data;

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Serializable getData() {
        return data;
    }

    public void setData(Serializable data) {
        this.data = data;
    }
}

I tried everything: changed Response interface into abstract class, put the initialising code into different part of code, moved getters/setters declarations into the interface, moved GWT.crate either into onModuleLoad method or into view implementation constructor.

Please help,

Jacek

Deserializing Lists?

What's the correct way to handle this?

/rest/clients -> returns json of List
/rest/clients/id -> returns json of Client

The main docs say to use
public static interface ClientMapper extends ObjectMapper {}

Should there then also be a
public static interface ClientMapper extends ObjectMapper<List> {} ?

Would this not generate duplicate code?

Issues when Compiling

Hey I am using 0.6.2 and getting these errors on compile: http://pastebin.com/vKJneM4x
Not sure why this is happening. Here is the implementation:

<module rename-to="ims">
    <!-- Inherit the core Web Toolkit stuff -->
    <inherits name="com.google.gwt.user.User" />
    <inherits name="com.google.gwt.logging.Logging"/>

    <set-property name="gwt.logging.consoleHandler" value="DISABLED"/>
    <set-property name="gwt.logging.popupHandler" value="DISABLED" />

    <extend-property name="locale" values="en"></extend-property>

    <!-- Core module inherits -->
    <inherits name="nz.co.doltech.framework.module.Framework" />
    <inherits name="nz.co.doltech.ims.Resources" />

    <!-- Theme module inherits -->
    <inherits name="nz.co.doltech.framework.themes.SyrenaTheme"/>

    <!-- GXT -->
    <!--stylesheet src="reset.css" /-->
    <!--inherits name='com.sencha.gxt.ui.GXT' /-->

    <!-- GXT Theme -->
    <!-- <inherits name='com.sencha.gxt.theme.blue.Blue'/> -->
    <!-- <inherits name='com.sencha.gxt.theme.gray.Gray' /> -->
    <!--inherits name="com.sencha.gxt.theme.neptune.Theme" /-->

    <!-- Library module inherits -->
    <inherits name="com.gwtplatform.dispatch.rest.DispatchRest"/>
    <inherits name="com.gwtplatform.mvp.Mvp"/>
    <inherits name="com.gwtplatform.dispatch.rpc.DispatchRpc"/>
    <inherits name="com.google.gwt.uibinder.UiBinder"/>
    <inherits name="com.google.gwt.query.Query"/>

    <inherits name="org.gwtbootstrap3.GwtBootstrap3CDN"/>
    <inherits name="nz.co.doltech.framework.extensions.gwtbootstrap3.datepicker.Datepicker"/>

    <inherits name="org.atmosphere.gwt.Client"/>

    <replace-with class="org.atmosphere.gwt.client.impl.IEHTMLFileCometTransport">
      <when-type-is class="org.atmosphere.gwt.client.impl.CometTransport"/>
      <any>
        <when-property-is name="user.agent" value="ie6"/>
        <when-property-is name="user.agent" value="ie8"/>
        <when-property-is name="user.agent" value="ie9"/>
      </any>
    </replace-with>

    <!-- Framework module inherits -->
    <inherits name="nz.co.doltech.framework.libraries.maydu.validation.ValidationLibrary" />
    <inherits name="nz.co.doltech.framework.libraries.chosen.Chosen" />

    <!-- Module entry point -->
    <entry-point class="nz.co.doltech.ims.client.Application"/>

    <set-configuration-property name="gin.ginjector.modules" 
        value="nz.co.doltech.ims.client.gin.ClientModule" />

    <set-configuration-property name="gwtp.bootstrapper"  
         value="nz.co.doltech.ims.client.BootstrapperImpl"/>

    <set-configuration-property name="gwtp.prebootstrapper"  
         value="nz.co.doltech.ims.client.BootstrapperImpl.PreBootstrapperImpl"/>

    <extend-configuration-property name="document.compatMode" value="BackCompat" />

    <!-- Specify the paths for translatable code -->
    <source path="client" />
    <source path="shared" />

    <generate-with class="com.google.gwt.uibinder.rebind.FixedUiBinderGenerator">
        <when-type-assignable class="com.google.gwt.uibinder.client.UiBinder"/>
    </generate-with>

    <!-- RPC Serialization Ignores -->
    <extend-configuration-property name="rpc.blacklist" value="javax.*"/>
    <extend-configuration-property name="rpc.blacklist" value="com.google.gwt.user.client.ui.*"/>
    <extend-configuration-property name="rpc.blacklist" value="com.google.gwt.query.client.*"/>
    <extend-configuration-property name="rpc.blacklist" value="com.google.gwt.aria.client.*"/>
    <extend-configuration-property name="rpc.blacklist" value="com.google.gwt.dom.client.*"/>
    <extend-configuration-property name="rpc.blacklist" value="com.google.gwt.validation.client.*"/>
    <extend-configuration-property name="rpc.blacklist" value="nz.co.doltech.framework.extensions.gwtbootstrap3.client.*"/>
    <extend-configuration-property name="rpc.blacklist" value="nz.co.doltech.framework.libraries.maydu.validation.client.*"/>
    <extend-configuration-property name="rpc.blacklist" value="nz.co.doltech.framework.themes.syrena.ui.*"/>
</module>

com.gwtplatform.dispatch.rest.DispatchRest

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.6.1//EN"
        "https://raw.githubusercontent.com/gwtproject/gwt/2.6.1/distro-source/core/src/gwt-module.dtd">
<module>
    <inherits name="com.gwtplatform.common.ClientsCommon"/>
    <inherits name="com.gwtplatform.dispatch.DispatchCommonClient"/>
    <inherits name="com.google.common.base.Base"/>
    <inherits name="com.google.common.collect.Collect"/>
    <inherits name="com.google.gwt.inject.Inject"/>

    <inherits name="com.google.gwt.http.HTTP"/>
    <inherits name="com.google.gwt.json.JSON"/>
    <inherits name="com.github.nmorel.gwtjackson.GwtJackson"/>

    <!-- Specify the paths for translatable code -->
    <source path='client'/>
    <source path='shared'/>

    <entry-point class='com.gwtplatform.dispatch.rest.client.RestDispatcherController'/>

    <extend-configuration-property name="gin.classloading.exceptedPackages" value="javax.ws.rs"/>

    <extend-configuration-property name="gin.ginjector.modules"
            value="com.gwtplatform.dispatch.rest.client.RestGinModule"/>

    <generate-with class="com.gwtplatform.dispatch.rest.rebind.VelocityGenerator">
        <when-type-is class="com.gwtplatform.dispatch.rest.client.RestDispatcherController"/>
    </generate-with>
</module>

That's it. I use Ivy dependency manager and all the jars are i the classpath and war (webapp) directory. Not sure what is going on here.

     [java]          Invoking generator com.google.gwt.inject.rebind.GinjectorGenerator
     [java]             [ERROR] Error injecting com.gwtplatform.dispatch.rest.client.ActionMetadataProvider: Unable to create or inherit binding: No @Inject or default constructor found for com.gwtplatform.dispatch.rest.client.ActionMetadataProvider
     [java]   Path to required node:
     [java] com.gwtplatform.dispatch.rest.client.RestRequestBuilderFactory [com.gwtplatform.dispatch.rest.client.gin.RestDispatchAsyncModule.configureDispatch(RestDispatchAsyncModule.java:100)]
     [java]  -> com.gwtplatform.dispatch.rest.client.DefaultRestRequestBuilderFactory [com.gwtplatform.dispatch.rest.client.gin.RestDispatchAsyncModule.configureDispatch(RestDispatchAsyncModule.java:100)]
     [java]  -> com.gwtplatform.dispatch.rest.client.ActionMetadataProvider [@Inject constructor of com.gwtplatform.dispatch.rest.client.DefaultRestRequestBuilderFactory]
     [java]             [ERROR] Error injecting com.gwtplatform.dispatch.rest.client.serialization.JacksonMapperProvider: Unable to create or inherit binding: No @Inject or default constructor found for com.gwtplatform.dispatch.rest.client.serialization.JacksonMapperProvider
     [java]   Path to required node:
     [java] com.gwtplatform.dispatch.rest.client.serialization.Serialization [com.gwtplatform.dispatch.rest.client.gin.RestDispatchAsyncModule.configureDispatch(RestDispatchAsyncModule.java:104)]
     [java]  -> com.gwtplatform.dispatch.rest.client.serialization.JsonSerialization [com.gwtplatform.dispatch.rest.client.gin.RestDispatchAsyncModule.configureDispatch(RestDispatchAsyncModule.java:104)]
     [java]  -> com.gwtplatform.dispatch.rest.client.serialization.JacksonMapperProvider [@Inject constructor of com.gwtplatform.dispatch.rest.client.serialization.JsonSerialization]
     [java]    [ERROR] Errors in 'gen/com/gwtplatform/mvp/client/DesktopGinjectorProvider.java'
     [java]       [ERROR] Line 8: Failed to resolve 'com.gwtplatform.mvp.client.DesktopGinjector' via deferred binding

A question about the creation of Beans

I noticed that currently beans are created via 'new' keyword, my question is can we configure an object type to invoke a GWT.create creation? I'm not too well versed with GWT generators but I want my objects to automatically call this when created from the server, since they need to be deferred and rebound with another generator.

Is this possible or even logical? Thanks!

Failing GWT compilation due to jackson-annotations

When including your library in my project, here's where the GWT compilation fails:

[INFO]    Validating units:
[INFO]       [ERROR] Errors in 'jar:file:/[...]/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.2.3/jackson-annotations-2.2.3-sources.jar!/com/fasterxml/jackson/annotation/JsonAutoDetect.java'
[INFO]          [ERROR] Line 79: No source code is available for type java.lang.reflect.Member; did you forget to inherit a required module?
[INFO]          [ERROR] Line 86: No source code is available for type java.lang.reflect.Modifier; did you forget to inherit a required module?
[INFO]       [ERROR] Errors in 'jar:file:/[...]/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.2.3/jackson-annotations-2.2.3-sources.jar!/com/fasterxml/jackson/annotation/JsonFormat.java'
[INFO]          [ERROR] Line 188: No source code is available for type java.util.TimeZone; did you forget to inherit a required module?
[INFO]    [ERROR] Aborting compile due to errors in some input files 

I think your <inherits name="com.fasterxml.jackson.annotation.JacksonAnnotation" /> is causing this?

Failed running Person example in README

I tried running your example in the README.

First of all, I think you should remove <scope>provided</scope> from

<dependency>
  <groupId>com.github.nmorel.gwtjackson</groupId>
  <artifactId>gwt-jackson</artifactId>
  <version>0.1.0</version>
  <scope>provided</scope>
</dependency>

in the README, otherwise users will not be able to resolve the dependency at runtime.

Finally, I tried your example using the Person class. Serialization to a String works just fine. However, when I try to deserialize the string into a Person, I run into a JsonDeserializationException exception:

// ...
Caused by: com.github.nmorel.gwtjackson.client.exception.JsonDeserializationException: Cannot instantiate the type
    at com.github.nmorel.gwtjackson.client.JsonDeserializationContext.traceError(JsonDeserializationContext.java:84)
    at com.github.nmorel.gwtjackson.client.JsonDeserializationContext.traceError(JsonDeserializationContext.java:96)
    at com.github.nmorel.gwtjackson.client.deser.bean.AbstractBeanJsonDeserializer.doDeserialize(AbstractBeanJsonDeserializer.java:129)
    at com.github.nmorel.gwtjackson.client.JsonDeserializer.deserialize(JsonDeserializer.java:31)
    at com.github.nmorel.gwtjackson.client.AbstractObjectMapper.read(AbstractObjectMapper.java:24)
    at com.github.nmorel.gwtjackson.client.AbstractObjectMapper.read(AbstractObjectMapper.java:17)
    at com.arcbees.gaestudio.client.application.ApplicationPresenter.onBind(ApplicationPresenter.java:93)

// ...

Here's what the fields of AbstractBeanJsonDeserializer look like when I'm stepping into the public T doDeserialize( JsonReader reader, JsonDeserializationContext ctx ) method:

screen shot 2013-11-21 at 4 17 54 pm

Any ideas?

Thanks a lot, I really like where this project is going so far.

Serialization Compilation Issues

Getting build errors while the serialization is compiling. Not even sure why its trying to compile this class for serialization tbh:

Errors in 'H:\Global\Java\Workspace\ims-project\ims\target\.generated\java\util\ComparatorBeanJsonSerializerImpl.java'
[INFO]             Line 15: The type com.google.common.primitives.Chars.LexicographicalComparator is not visible
[INFO]             Line 15: The type com.google.common.primitives.Chars.LexicographicalComparator is not visible
[INFO]             Line 17: The type com.google.common.primitives.Chars.LexicographicalComparator is not visible
[INFO]             Line 18: The type com.google.common.primitives.Chars.LexicographicalComparator is not visible
[INFO]             Line 22: The type com.google.common.collect.ByFunctionOrdering is not visible
[INFO]             Line 22: The type com.google.common.collect.ByFunctionOrdering is not visible
[INFO]             Line 22: F cannot be resolved to a type
[INFO]             Line 29: The type com.google.common.primitives.Ints.LexicographicalComparator is not visible
[INFO]             Line 29: The type com.google.common.primitives.Ints.LexicographicalComparator is not visible
[INFO]             Line 31: The type com.google.common.primitives.Ints.LexicographicalComparator is not visible
[INFO]             Line 32: The type com.google.common.primitives.Ints.LexicographicalComparator is not visible
[INFO]             Line 36: The type com.google.common.collect.NullsFirstOrdering is not visible
[INFO]             Line 36: The type com.google.common.collect.NullsFirstOrdering is not visible
[INFO]             Line 43: The type com.google.common.collect.NullsLastOrdering is not visible
[INFO]             Line 43: The type com.google.common.collect.NullsLastOrdering is not visible
[INFO]             Line 50: The type com.google.common.collect.NaturalOrdering is not visible
[INFO]             Line 50: The type com.google.common.collect.NaturalOrdering is not visible
[INFO]             Line 57: The type com.google.common.primitives.Longs.LexicographicalComparator is not visible
[INFO]             Line 57: The type com.google.common.primitives.Longs.LexicographicalComparator is not visible
[INFO]             Line 59: The type com.google.common.primitives.Longs.LexicographicalComparator is not visible
[INFO]             Line 60: The type com.google.common.primitives.Longs.LexicographicalComparator is not visible
[INFO]             Line 64: The type com.google.common.collect.ComparatorOrdering is not visible
[INFO]             Line 64: The type com.google.common.collect.ComparatorOrdering is not visible
[INFO]             Line 71: The type com.google.common.collect.ReverseNaturalOrdering is not visible
[INFO]             Line 71: The type com.google.common.collect.ReverseNaturalOrdering is not visible
[INFO]             Line 78: The type com.google.common.primitives.UnsignedLongs.LexicographicalComparator is not visible
[INFO]             Line 78: The type com.google.common.primitives.UnsignedLongs.LexicographicalComparator is not visible
[INFO]             Line 80: The type com.google.common.primitives.UnsignedLongs.LexicographicalComparator is not visible
[INFO]             Line 81: The type com.google.common.primitives.UnsignedLongs.LexicographicalComparator is not visible
[INFO]             Line 85: The type com.google.common.collect.ExplicitOrdering is not visible
[INFO]             Line 85: The type com.google.common.collect.ExplicitOrdering is not visible
[INFO]             Line 92: The type com.google.common.collect.AllEqualOrdering is not visible
[INFO]             Line 92: The type com.google.common.collect.AllEqualOrdering is not visible
[INFO]             Line 99: The type com.google.common.primitives.Doubles.LexicographicalComparator is not visible
[INFO]             Line 99: The type com.google.common.primitives.Doubles.LexicographicalComparator is not visible
[INFO]             Line 101: The type com.google.common.primitives.Doubles.LexicographicalComparator is not visible
[INFO]             Line 102: The type com.google.common.primitives.Doubles.LexicographicalComparator is not visible
[INFO]             Line 106: The type com.google.common.collect.CompoundOrdering is not visible
[INFO]             Line 106: The type com.google.common.collect.CompoundOrdering is not visible
[INFO]             Line 113: The type com.google.common.primitives.SignedBytes.LexicographicalComparator is not visible
[INFO]             Line 113: The type com.google.common.primitives.SignedBytes.LexicographicalComparator is not visible
[INFO]             Line 115: The type com.google.common.primitives.SignedBytes.LexicographicalComparator is not visible
[INFO]             Line 116: The type com.google.common.primitives.SignedBytes.LexicographicalComparator is not visible
[INFO]             Line 120: Syntax error on token "<", ? expected after this token
[INFO]             Line 120: Syntax error on token "<", ? expected after this token
[INFO]             Line 120: Syntax error, insert "}" to complete ClassBody
[INFO]             Line 120: Syntax error, insert ")" to complete Expression
[INFO]             Line 120: Syntax error, insert ";" to complete Statement
[INFO]             Line 122: The method newSerializer() of type ComparatorBeanJsonSerializerImpl<T> must override or implement a supertype method
[INFO]             Line 123: Type mismatch: cannot convert from FilterSortDataProvider_DataColumnBeanJsonSerializerImpl to AbstractBeanJsonSerializer<?>
[INFO]             Line 124: Syntax error on tokens, delete these tokens
[INFO]             Line 127: map cannot be resolved
[INFO]             Line 127: The type com.google.common.collect.Ordering.ArbitraryOrdering is not visible
[INFO]             Line 127: The type com.google.common.collect.Ordering.ArbitraryOrdering is not visible
[INFO]             Line 134: map cannot be resolved
[INFO]             Line 134: The type com.google.common.primitives.Booleans.LexicographicalComparator is not visible
[INFO]             Line 134: The type com.google.common.primitives.Booleans.LexicographicalComparator is not visible
[INFO]             Line 136: The type com.google.common.primitives.Booleans.LexicographicalComparator is not visible
[INFO]             Line 137: The type com.google.common.primitives.Booleans.LexicographicalComparator is not visible
[INFO]             Line 141: map cannot be resolved
[INFO]             Line 141: The type com.google.common.collect.ReverseOrdering is not visible
[INFO]             Line 141: The type com.google.common.collect.ReverseOrdering is not visible
[INFO]             Line 148: map cannot be resolved
[INFO]             Line 148: The type com.google.common.primitives.Floats.LexicographicalComparator is not visible
[INFO]             Line 148: The type com.google.common.primitives.Floats.LexicographicalComparator is not visible
[INFO]             Line 150: The type com.google.common.primitives.Floats.LexicographicalComparator is not visible
[INFO]             Line 151: The type com.google.common.primitives.Floats.LexicographicalComparator is not visible
[INFO]             Line 155: map cannot be resolved
[INFO]             Line 155: The type com.google.common.primitives.UnsignedInts.LexicographicalComparator is not visible
[INFO]             Line 155: The type com.google.common.primitives.UnsignedInts.LexicographicalComparator is not visible
[INFO]             Line 157: The type com.google.common.primitives.UnsignedInts.LexicographicalComparator is not visible
[INFO]             Line 158: The type com.google.common.primitives.UnsignedInts.LexicographicalComparator is not visible
[INFO]             Line 162: map cannot be resolved
[INFO]             Line 162: The type com.google.common.collect.LexicographicalOrdering is not visible
[INFO]             Line 162: The type com.google.common.collect.LexicographicalOrdering is not visible
[INFO]             Line 169: map cannot be resolved
[INFO]             Line 169: The type com.google.common.primitives.Shorts.LexicographicalComparator is not visible
[INFO]             Line 169: The type com.google.common.primitives.Shorts.LexicographicalComparator is not visible
[INFO]             Line 171: The type com.google.common.primitives.Shorts.LexicographicalComparator is not visible
[INFO]             Line 172: The type com.google.common.primitives.Shorts.LexicographicalComparator is not visible
[INFO]             Line 176: map cannot be resolved
[INFO]             Line 176: The type com.google.common.collect.UsingToStringOrdering is not visible
[INFO]             Line 176: The type com.google.common.collect.UsingToStringOrdering is not visible
[INFO]             Line 183: map cannot be resolved to a variable
[INFO]             See snapshot: C:\Users\Ben\AppData\Local\Temp\java.util.ComparatorBeanJsonSerializerImpl1868991831854655945.java
[INFO]          Errors in 'H:\Global\Java\Workspace\ims-project\ims\target\.generated\nz\co\doltech\framework\module\client\core\FilterSortDataProvider_DataColumnBeanJsonSerializerImpl.java'
[INFO]             Line 3: Syntax error on token ">", delete this token
[INFO]             Line 3: Syntax error on token "<", ? expected after this token
[INFO]             Line 8: The type FilterSortDataProvider<T>.DataColumn is not generic; it cannot be parameterized with arguments <>
[INFO]             Line 8: T cannot be resolved to a type
[INFO]             Line 9: The type FilterSortDataProvider<T>.DataColumn is not generic; it cannot be parameterized with arguments <>
[INFO]             Line 9: T cannot be resolved to a type
[INFO]             Line 9: The type FilterSortDataProvider<T>.DataColumn is not generic; it cannot be parameterized with arguments <>
[INFO]             Line 9: T cannot be resolved to a type
[INFO]             Line 11: The type FilterSortDataProvider<T>.DataColumn is not generic; it cannot be parameterized with arguments <>
[INFO]             Line 11: T cannot be resolved to a type
[INFO]             Line 23: The type FilterSortDataProvider<T>.DataColumn is not generic; it cannot be parameterized with arguments <>
[INFO]             Line 23: T cannot be resolved to a type
[INFO]             Line 39: The method getSerializedType() of type FilterSortDataProvider_DataColumnBeanJsonSerializerImpl must override or implement a supertype method
[INFO]             See snapshot: C:\Users\Ben\AppData\Local\Temp\nz.co.doltech.framework.module.client.core.FilterSortDataProvider_DataColumnBeanJsonSerializerImpl1343062887097301408.java

The generated file:

package nz.co.doltech.framework.module.client.core;

public class FilterSortDataProvider_DataColumnBeanJsonSerializerImpl> extends com.github.nmorel.gwtjackson.client.ser.bean.AbstractBeanJsonSerializer<nz.co.doltech.framework.module.client.core.FilterSortDataProvider<T>.DataColumn<>> {

  public FilterSortDataProvider_DataColumnBeanJsonSerializerImpl() {}

  @Override
  protected java.util.Map<java.lang.String, com.github.nmorel.gwtjackson.client.ser.bean.BeanPropertySerializer<nz.co.doltech.framework.module.client.core.FilterSortDataProvider<T>.DataColumn<>, ?>> initSerializers() {
    java.util.Map<java.lang.String, com.github.nmorel.gwtjackson.client.ser.bean.BeanPropertySerializer<nz.co.doltech.framework.module.client.core.FilterSortDataProvider<T>.DataColumn<>, ?>> map = new java.util.LinkedHashMap<java.lang.String, com.github.nmorel.gwtjackson.client.ser.bean.BeanPropertySerializer<nz.co.doltech.framework.module.client.core.FilterSortDataProvider<T>.DataColumn<>, ?>>(2);

    map.put("name", new com.github.nmorel.gwtjackson.client.ser.bean.BeanPropertySerializer<nz.co.doltech.framework.module.client.core.FilterSortDataProvider<T>.DataColumn<>, java.lang.String>() {
      @Override
      protected com.github.nmorel.gwtjackson.client.JsonSerializer<?> newSerializer() {
        return com.github.nmorel.gwtjackson.client.ser.StringJsonSerializer.getInstance();
      }

      @Override
      public java.lang.String getValue(nz.co.doltech.framework.module.client.core.FilterSortDataProvider<T>.DataColumn<> bean, com.github.nmorel.gwtjackson.client.JsonSerializationContext ctx) {
        return bean.getName();
      }
    });

    map.put("label", new com.github.nmorel.gwtjackson.client.ser.bean.BeanPropertySerializer<nz.co.doltech.framework.module.client.core.FilterSortDataProvider<T>.DataColumn<>, java.lang.String>() {
      @Override
      protected com.github.nmorel.gwtjackson.client.JsonSerializer<?> newSerializer() {
        return com.github.nmorel.gwtjackson.client.ser.StringJsonSerializer.getInstance();
      }

      @Override
      public java.lang.String getValue(nz.co.doltech.framework.module.client.core.FilterSortDataProvider<T>.DataColumn<> bean, com.github.nmorel.gwtjackson.client.JsonSerializationContext ctx) {
        return bean.getLabel();
      }
    });

    return map;
  }

  @Override
  public java.lang.Class getSerializedType() {
    return nz.co.doltech.framework.module.client.core.FilterSortDataProvider.DataColumn.class;
  }

}

Not really sure what's going on here. Any ideas?

License

I looked at a few source files, and there's no license header.

What's the license? Can I use this lib on a private, for-profit project?

Thanks man!

Failing to instantiate interface Type

So I have a situation coming from GWT RPC serialization. GWT allowed you to provide an interface type as a return type and then you return an object that implements that interface. It appears gwt-jackson doesn't offer this kind of deserialization?

I have an interface called ProcessPageData which has 2 implementors:

  • OpenIncidentData
  • InvestigationData
Unable to deserialize response. An unexpected error occurred.
Cannot instantiate the type nz.co.doltech.ims.shared.core.ProcessPageData`

Depending on the process that is being loaded it returns the appropriate data in the form of the class. This worked fine previously and I would love to know how this could be done with jackson.

Cheers!
(Also, sorry I don't know where else to post questions that I have :D)

Turbo GWT HTTP integration

Hi @nmorel, congratulations for your excellent project! It is well designed.

I'm working on Turbo GWT HTTP - a project for GWT client/server communication. It's a high level API for managing and performing requests gracefully.

I let the de/serialization job for third-part libraries. By studying the available solutions, I really liked this one.

It would be great if you could help me out on building a integration for auto-serialization in turbogwt-http with gwt-jackson.

The interfaces for de/serialization are Serializer and Deserializer (joined in Serdes).

In turbogwt-http there's a main component, called Requestor, responsible for integrating the others. It's a factory for creating requests and later enhancing them (analogous to the Jackson ObjectMapper for serialization puporses). Custom serdes must be registered in the Requestor in order to be used in the requests.

It would be interesting to design some auto-discovered serdes registration for custom objects.

Collections serialization

Are there any difference in the de/serialization process of Set, List and any of these implementations?

Add support for mix-in annotations

I am very interested in using your product. In my project, Jackson is currently being used on the server-side to do serialization/deserialization into json. We'd love to be able to integrate gwt-jackson into our GWT GUI as well.

However, we use mix-in annotations (mostly to @JsonIgnore methods) so that we can keep our POJOs free of serialization-related annotations.

It would be great if gwt-jackson supported mix-in annotations.

Info about mix-in annotaitons can be found here: http://wiki.fasterxml.com/JacksonMixInAnnotations

@JsonIdentityInfo with custom serializer/deserializer for ID property

I found another issue.

If using @JsonIdentityInfo, to eliminate serializing the same instances of objects, gwt-jackson doesn't work, if "id" property is a parameter of the @JsonCreator constructor. I get an error:

  • com.github.nmorel.gwtjackson.client.exception.JsonDeserializationException: java.lang.NullPointerException
    • at com.github.nmorel.gwtjackson.client.JsonDeserializationContext.traceError(JsonDeserializationContext.java:213)
    • at com.github.nmorel.gwtjackson.client.JsonDeserializationContext.traceError(JsonDeserializationContext.java:228)
    • at com.github.nmorel.gwtjackson.client.AbstractObjectMapper.read(AbstractObjectMapper.java:81)
    • at com.github.nmorel.gwtjackson.client.AbstractObjectMapper.read(AbstractObjectMapper.java:44)

I prepared a simplified test case (I omitted the obvious imports and other non-important code).
I have a simple TestDto, which has a list of "X" objects.

public class TestDto {
    public List<X> list;
}

@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
public class X {
    public String id;
    public String value;

    public X() {
    }

    @JsonCreator
    public X(@JsonProperty("id") String id) {
        this.id = id;
    }

    @JsonProperty
    public void setId(String id) {
        this.id = id;
    }
}

The input JSON string that I try to deserialize into TestDto:

{
  "list" : 
  [ 
    {
      "id" : "1",
      "value" : "abc"
    }, 
    {
      "id" : "2",
      "value" : "test"
    }, 
    "1" 
  ]
}

However, if I remove "id" property from @JsonCreator, then it works.

The problem is that gwt-jackson generator doesn't include the properties that are parameters of @JsonCreate in the "AbstractBeanJsonDeserializer.initDeserializers" method. But @JsonIdentityInfo needs such a property to be included in the list of deserializers. The "setId" setter in my example is there only to demonstrate that even an explicit setter doesn't force the property's deserializer to be added to the list.

So I guess gwt-jackson should either include all the properties in the list of deserializers (would cause a small overhead, that would be later eliminated by gwt compiler), or at least those that are referenced by @JsonIdentityInfo.

Guava dependency

I realized that gwt-jackson has guava as a dependency. Is this required, or optional?
Guava is a library of considerable size, and having the option of what you want to depend is always good.

Disable "Enum" and "EnumMap" warnings

If I have a Map<> that contains some wildcard parameterized type as a value, like:

Map<String, List<SomeClass<?>>>

then I get warnings like:

Type 'java.lang.Enum' is not supported as map's key
Subtype 'java.util.EnumMap' is not supported. We ignore it.

I know it's just a warning and since my parameter will never be an Enum or EnumMap, I can ignore it. But this warning still puts junk into the log. And this happens for every such Map. So with many Maps, I get many warnings.

Is there any way to disable or hide it?

Add configuration to set Map implementation used in

I identified two places where Map implementations are used:
https://github.com/nmorel/gwt-jackson/blob/master/gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/rebind/BeanJsonSerializerCreator.java#L146
https://github.com/nmorel/gwt-jackson/blob/master/gwt-jackson/src/main/java/com/github/nmorel/gwtjackson/rebind/BeanJsonDeserializerCreator.java#L324

I would like to be able to change these implementations.
Particularly, I would set them to LightMap, which is a lightweight Map implementation from String to Objects.

GWT project without Maven

I would like to use gwt-jackson in the client side in my GWT project without Maven. Which jars do I need from which urls exactly?

I tried the following without success:

Generics : Bounded wildcards

Does gwt-jackson support bounded wildcards? I'm having compilation errors, but I was just wondering whether you've actually implemented support for bounded wildcards.

E.g.:

public class MedicationDto {
// ...
    private List<? extends Therapy> therapies;
// ...
}

I'm using gwt-jackson 0.4.0.

Deserialize "Abc extends ArrayList<T>/HashMap<T>"

I just found this Project and think it is awesome to have this.

But i have a small issue. gwt-jackson can't deserialize some of my classes.

I have:

class StuffMap extends HashMap<String, Something> {
// bunch of helper methods but no json fields.
}

and

class StuffList extends ArrayList<SomethingElse> {
// bunch of helper methods but no json fields.
}

While gwt-jackson works if have ObjectMapper<Map<String, Something>> it does not if i do ObjectMapper<StuffMap>. With original Jackson this works and it would be awesome if it would be possible to use this with gwt-jackson too, to have easier access to those helper methods.

Thanks.

should not process classes with @JsonIgnoreType

When using Object or unbounded in some serializable class, gwt-jackson will try to process all the classes in the class path, as every class matches Object or . This can lead to many problems.

We already talked about the case of the class, parameterized with itself, like "class A<T extends A>". However, such classes were found to cause stack overflow, so we rewrote such classes to be simple un-parameterized classes.

But, if we have such self-parameterized class which is never meant to be used by gwt-jackson, it's still processed in the above cases, where gwt-jackson is processing all the class candidates. It's just enough that such class is in the class path, and is found and causes stack overflow.

gwt-jackson processes such classes, even if they are intentionally annotated with @JsonIgnoreType.

Is there anything to do in such a case? Like whitelisting or blacklisting the classes, or packages, or something? To process every class on the classpath is just not ok, even if we forget the fact that this can be very slow.

GWT compilation fails with com.fasterxml.jackson.annotation.ObjectIdGenerators.Base is not visible

After we added gwtp-dispatch-rest which depends on gwt-jackson our project GWT compilation started failing with these messages:

[INFO]       Rebinding se.homework.hwbs.common.client.rpc.ProblemReportingRpcService
[INFO]          Invoking generator com.google.gwt.user.rebind.rpc.ServiceInterfaceProxyGenerator
[INFO]             Generating client proxy for remote service interface 'se.homework.hwbs.common.client.rpc.ProblemReportingRpcService'
[INFO]                Analyzing 'se.homework.hwbs.common.client.rpc.ProblemReportingRpcService' for serializable types
[INFO]                   Analyzing methods:
[INFO]                      public abstract void reportProblem(java.lang.String browser, java.lang.String os, java.lang.String userAgent, java.lang.String stepsToReproduce, java.lang.String clientStackTrace, com.allen_sauer.gwt.log.shared.WrappedClientThrowable exception, com.google.gwt.core.client.GwtContext context)
[INFO]                         Parameter: com.google.gwt.core.client.GwtContext context
[INFO]                            com.google.gwt.core.client.GwtContext
[INFO]                               Verifying instantiability
[INFO]                                  com.google.gwt.core.client.GwtContext
[INFO]                                     Analyzing the fields of type 'com.google.gwt.core.client.GwtContext' that qualify for serialization
[INFO]                                        private java.util.List<java.io.Serializable> log
[INFO]                                           java.util.List<java.io.Serializable>
[INFO]                                              Verifying instantiability
[INFO]                                                 java.util.Collections.SingletonList<java.io.Serializable>
[INFO]                                                    Checking parameters of 'java.util.Collections.SingletonList<java.io.Serializable>'
[INFO]                                                       Checking type argument 0 of type 'java.util.Collections.SingletonList<E>' because it is directly exposed in this type or in one of its subtypes
[INFO]                                                          java.io.Serializable
[INFO]                                                             Verifying instantiability
[INFO]                                                                com.google.common.collect.RegularImmutableSortedMap<? extends java.lang.Object, ? extends java.lang.Object>
[INFO]                                                                   [WARN] Checking all subtypes of Object which qualify for serialization
[INFO]                                                                      com.fasterxml.jackson.annotation.ObjectIdGenerator<T>
[INFO]                                                                         Verifying instantiability
[INFO]                                                                            com.fasterxml.jackson.annotation.ObjectIdGenerators.UUIDGenerator
[INFO]                                                                               Analyzing the fields of type 'com.fasterxml.jackson.annotation.ObjectIdGenerators.Base<java.util.UUID>' that qualify for serialization
[INFO]                                                                                  [WARN] Field 'protected final java.lang.Class<?> _scope' will not be serialized because it is final
[INFO]                                                                            com.fasterxml.jackson.annotation.ObjectIdGenerators.IntSequenceGenerator
[INFO]                                                                               Analyzing the fields of type 'com.fasterxml.jackson.annotation.ObjectIdGenerators.Base<java.lang.Integer>' that qualify for serialization
[INFO]                                                                                  [WARN] Field 'protected final java.lang.Class<?> _scope' will not be serialized because it is final
[INFO]                                                                      java.lang.Exception
[INFO]                                                                         Verifying instantiability
[INFO]                                                                            se.homework.hwbs.domain.shared.OutdatedProxyVersionException
[INFO]                                                                               Analyzing the fields of type 'se.homework.hwbs.domain.shared.OutdatedProxyVersionException' that qualify for serialization
[INFO]                                                                                  [WARN] Field 'public final boolean optimisticLocking' will not be serialized because it is final
[INFO]                                                                      se.homework.hwbs.domain.shared.util.FunctionUtils.Constant<Q, E>
[INFO]                                                                         Verifying instantiability
[INFO]                                                                            se.homework.hwbs.domain.shared.util.FunctionUtils.Constant<Q, E>
[INFO]                                                                               Analyzing the fields of type 'se.homework.hwbs.domain.shared.util.FunctionUtils.Constant<Q, E>' that qualify for serialization
[INFO]                                                                                  [WARN] Field 'private final E value' will not be serialized because it is final
[INFO]                                                                      com.google.gwt.validation.client.impl.PathImpl
[INFO]                                                                         Verifying instantiability
[INFO]                                                                            com.google.gwt.validation.client.impl.PathImpl
[INFO]                                                                               Analyzing the fields of type 'com.google.gwt.validation.client.impl.PathImpl' that qualify for serialization
[INFO]                                                                                  [WARN] Field 'private final java.util.List<javax.validation.Path.Node> nodes' will not be serialized because it is final
[INFO]                                                                se.homework.hwbs.domain.shared.util.FunctionUtils.Constant<? extends java.lang.Object, ? extends java.lang.Object>
[INFO]                                                                   Analyzing the fields of type 'se.homework.hwbs.domain.shared.util.FunctionUtils.Constant<? extends java.lang.Object, ? extends java.lang.Object>' that qualify for serialization
[INFO]                                                                      [WARN] Field 'private final E value' will not be serialized because it is final
[INFO]    Adding '879' new generated units
[INFO]       Validating units:
[INFO]          [ERROR] Errors in '.../target/.generated/com/fasterxml/jackson/annotation/ObjectIdGenerators_Base_FieldSerializer.java'
[INFO]             [ERROR] Line 10: The type com.fasterxml.jackson.annotation.ObjectIdGenerators.Base is not visible
[INFO]             [ERROR] Line 15: The type com.fasterxml.jackson.annotation.ObjectIdGenerators.Base is not visible
[INFO]             See snapshot: /tmp/com.fasterxml.jackson.annotation.ObjectIdGenerators_Base_FieldSerializer1719221523098467839.java
[INFO]    [ERROR] Errors in '.../target/.generated/com/fasterxml/jackson/annotation/ObjectIdGenerators_Base_FieldSerializer.java'
[INFO]       [ERROR] Line 10: The type com.fasterxml.jackson.annotation.ObjectIdGenerators.Base is not visible
[INFO]       [ERROR] Line 15: The type com.fasterxml.jackson.annotation.ObjectIdGenerators.Base is not visible
[INFO]       See snapshot: /tmp/com.fasterxml.jackson.annotation.ObjectIdGenerators_Base_FieldSerializer8805528719787639687.java

Meaningful project dependencies:

com.gwtplatform:gwtp-dispatch-rest:1.2.1
  com.gwtplatform:gwtp-clients-common:1.2.1
    org.apache.maven:maven-artifact:3.1.1
      org.codehaus.plexus:plexus-utils:3.0.15
  com.gwtplatform:gwtp-dispatch-common-client:1.2.1
    com.gwtplatform:gwtp-dispatch-common-shared:1.2.1
  com.github.nmorel.gwtjackson:gwt-jackson:0.4.0
    com.fasterxml.jackson.core:jackson-annotations:sources:2.3.0

Probably, this issue is somehow related to issue #3. But that was fixed in 0.2.0. Our project transitively depends on 0.4.0. We tried to fix the problem by upgrading maven dependencies to their latest releases and even snapshots, but it didn`t help.

Is it a bug or error in our configuration?

I could be wrong, but it seems like some kind JSON-related auxiliary classes are generated while GWT compiles our GWT standard RPC services. I am not sure that we actually need it. So any suggested workarounds are highly appreciated!

2D Arrays - Cannot specify an array dimension after an empty dimension

Attempting to create a deserializer for a type containing a 2D array generates Java classes with fail to compile to GWT.

[ERROR] Errors in '/Users/danieljones/git/f2pmsoppa-libgdx/html/target/.generated/com/binarytweed/f2pmsoppa/terrain/GameMapDataBeanJsonDeserializerImpl.java'
[[ERROR] Line 33: Cannot specify an array dimension after an empty dimension

Here's a (simplified) example of the class that causes the problem:

public class GameMapData
{
    private final String[][] tileIds;


    public GameMapData(@JsonProperty("tileIds") String[][] tileIds)
    {
        super();
        this.tileIds = tileIds;
    }



    public String[][] getTileIds()
    {
        return tileIds;
    }

And here's the offending snippet of generated code:

private final com.github.nmorel.gwtjackson.client.deser.bean.HasDeserializerAndParameters<java.lang.String[][], com.github.nmorel.gwtjackson.client.JsonDeserializer<java.lang.String[][]>> deserializer_tileIds = new com.github.nmorel.gwtjackson.client.deser.bean.HasDeserializerAndParameters<java.lang.String[][], com.github.nmorel.gwtjackson.client.JsonDeserializer<java.lang.String[][]>>() {
        @Override
        protected com.github.nmorel.gwtjackson.client.JsonDeserializer<java.lang.String[][]> newDeserializer() {
          return com.github.nmorel.gwtjackson.client.deser.array.ArrayJsonDeserializer.newInstance(com.github.nmorel.gwtjackson.client.deser.array.ArrayJsonDeserializer.newInstance(com.github.nmorel.gwtjackson.client.deser.StringJsonDeserializer.getInstance(), new com.github.nmorel.gwtjackson.client.deser.array.ArrayJsonDeserializer.ArrayCreator<java.lang.String>(){
            @Override
            public java.lang.String[] create( int length ) {
              return new java.lang.String[length];
            }
          }), new com.github.nmorel.gwtjackson.client.deser.array.ArrayJsonDeserializer.ArrayCreator<java.lang.String[]>(){
            @Override
            public java.lang.String[][] create( int length ) {
              return new java.lang.String[][length]; //THIS IS WHERE IT FAILS TO COMPILE
            }
          });
        }

Add support for Enum with interfaces

I'm currently working on a big GWT project, and more precisely on a proof of concept to use JSON with Jackson on the server side, gwt-jackson on the front size. The RPC services we try to migrate use complex objects. I tried several libraries, gwt-jackson is the only one to purpose solutions for some difficulties (inheritance with generics, complex map keys...).

But I actually have problems with some enums, which have the particularity to implement interfaces. The current serializer/deserializer for enums are ok with plain simple enums, but do not permit the use of interfaces with JsonTypeInfo annotation, and enums implementing them. I don't think that's a heavy feature, but it would be a great one here =)

List serialization with element type information

I tried this use case: http://www.studytrails.com/java/json/java-jackson-Serialization-list.jsp

@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = As.PROPERTY, property = "@class")
@JsonSubTypes({ @Type(value = Lion.class, name = "lion"), @Type(value = Elephant.class, name = "elephant") })
public abstract class Animal {
    @JsonProperty("name")
    private String name;

    public Animal(String name) {
        this.name = name;
    }

   ...
}

class Elephant extends Animal { 
    @JsonCreator
    public Elephant(@JsonProperty("name") String name) {
        super(name);
    }

    ...
}

class Lion extends Animal {
    @JsonCreator
    public Lion(@JsonProperty("name") String name) {
        super(name);
    }

    ...
}

// In Xtend GWT code:

val lion = new Lion("Simba")
val elephant = new Elephant("Manny")
val List<Animal> animals = #[lion, elephant]

val AnimalListMapper animalListMapper = GWT.create(AnimalListMapper)
val AnimalMapper animalMapper = GWT.create(AnimalMapper)

GWT.log(animalMapper.write(animals.get(0))) // {"name":"Simba"}
GWT.log(animalListMapper.write(animals)) // [{"name":"Simba"},{"name":"Manny"}]

Is there a way to write/read type information along with the objects?
(I'm new to Jackson so probably I just don't use the correct annotations?)
Thanks for your help in advance!

Unsupported Media Type

I apologize if this isn't a gwt-jackson issue, I am just running out of options with this. I haven't changed anything that should be causing this issue and can't find a solution. If you have any advice I'd be really grateful to say the least.

com.gwtplatform.dispatch.shared.ActionException: Unsupported Media Type
    at com.gwtplatform.dispatch.rest.client.DefaultRestResponseDeserializer.deserialize(DefaultRestResponseDeserializer.java:49)
    at com.gwtplatform.dispatch.rest.client.RestDispatchCall.onResponseReceived(RestDispatchCall.java:114)
    at com.gwtplatform.dispatch.rest.client.RestDispatchCall.access$0(RestDispatchCall.java:110)
    at com.gwtplatform.dispatch.rest.client.RestDispatchCall$1.onResponseReceived(RestDispatchCall.java:100)
    at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:259)
    at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:412)
    at sun.reflect.GeneratedMethodAccessor140.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
    at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
    at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
    at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:338)
    at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:219)
    at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:576)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:284)
    at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
    at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
    at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:356)
    at sun.reflect.GeneratedMethodAccessor132.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
    at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
    at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
    at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:293)
    at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:547)
    at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
    at java.lang.Thread.run(Thread.java:722)

For some reason I can load the Incident object now, but I can't send it to the server. This was working earlier, then all of a sudden just stopped working and started throwing this error. Really hard for me to say what change is causing this though because they are all such light changes.

I tried reverting back to 0.6.2 but it still throws this exception.

Cheers

Examples for general ObjectMapper?

Is it possible to have one ObjectMapper instance that's capable of mapping many classes, like a regular Jackson ObjectMapper?

All the examples here seem to create one mapper per class (eg PersonMapper extends ObjectMapper {}), whereas a normal Jackson ObjectMapper can take any old class at runtime.

Thanks, and keep up the good work - this library could save me a lot of effort!

StringIndexOutOfBoundsException thrown

com.github.nmorel.gwtjackson.client.exception.JsonSerializationException: java.lang.StringIndexOutOfBoundsException: String index out of range: -17

I am getting this error when serializing a somewhat large object. What could be causing this?

How can I covert Object to List<String> ?

I am using resty-gwt and it i depends on your project.

I use Map<String,Object> as DTO both in server side and client side.

GWT

@Path("http://localhost:8081")
public interface WhService extends RestService {

  @POST
  @Path("/{methodUrl}")
  public void postRequest(@PathParam("methodUrl") String methodUrl,Map<String,Object> request,MethodCallback<Map<String, Object>> callback);


}

if the Object is String, I can convert it into String type.
But,if the Object is List, when i use

 (List<String>) whProduct.get("infoUrls")  //this one not work,java.lang.ClassCastExceptio

String sku = whProduct.get("sku"); //this one work.

Project does not compile with Java8

I tried to compile a project using gwt-jackson 0.7 with GWT2.8SNAPSHOT and Java8. I got the following errors:

Compiling module com.test.Test
   Tracing compile failure path for type 'com.github.nmorel.gwtjackson.client.JsonSerializationContext'
      [ERROR] Errors in 'com/github/nmorel/gwtjackson/client/JsonSerializationContext.java'
         [ERROR] Line 480: ObjectIdGenerator cannot be resolved to a type
         [ERROR] Line 470: ObjectIdGenerator cannot be resolved to a type
         [ERROR] Line 479: ObjectIdGenerator cannot be resolved to a type
         [ERROR] Line 468: ObjectIdGenerator cannot be resolved to a type
         [ERROR] Line 483: ObjectIdGenerator cannot be resolved to a type
         [ERROR] Line 253: ObjectIdGenerator cannot be resolved to a type
         [ERROR] Line 466: ObjectIdGenerator cannot be resolved to a type
         [ERROR] Line 467: ObjectIdGenerator cannot be resolved to a type
         [ERROR] Line 27: The import com.fasterxml.jackson.annotation.ObjectIdGenerator cannot be resolved
         [ERROR] Line 481: ObjectIdGenerator cannot be resolved to a type
   Tracing compile failure path for type 'com.github.nmorel.gwtjackson.client.deser.bean.TypeDeserializationInfo'
      [ERROR] Errors in 'com/github/nmorel/gwtjackson/client/deser/bean/TypeDeserializationInfo.java'
         [ERROR] Line 34: As cannot be resolved to a type
         [ERROR] Line 22: The import com.fasterxml.jackson.annotation.JsonTypeInfo cannot be resolved
         [ERROR] Line 44: As cannot be resolved to a type
         [ERROR] Line 55: As cannot be resolved to a type
         [ERROR] Line 43: As cannot be resolved to a type
         [ERROR] Line 54: As cannot be resolved to a type
   Tracing compile failure path for type 'com.github.nmorel.gwtjackson.client.ser.bean.TypeSerializationInfo'
      [ERROR] Errors in 'com/github/nmorel/gwtjackson/client/ser/bean/TypeSerializationInfo.java'
         [ERROR] Line 34: As cannot be resolved to a type
         [ERROR] Line 22: The import com.fasterxml.jackson.annotation.JsonTypeInfo cannot be resolved
         [ERROR] Line 44: As cannot be resolved to a type
         [ERROR] Line 55: As cannot be resolved to a type
         [ERROR] Line 43: As cannot be resolved to a type
         [ERROR] Line 54: As cannot be resolved to a type
   Tracing compile failure path for type 'com.github.nmorel.gwtjackson.client.deser.bean.AbstractIdentityDeserializationInfo'
      [ERROR] Errors in 'com/github/nmorel/gwtjackson/client/deser/bean/AbstractIdentityDeserializationInfo.java'
         [ERROR] Line 4: The import com.fasterxml.jackson.annotation.ObjectIdGenerator cannot be resolved
         [ERROR] Line 48: IdKey cannot be resolved to a type
         [ERROR] Line 47: IdKey cannot be resolved to a type
   Tracing compile failure path for type 'com.gwtplatform.dispatch.rest.client.DefaultRestRequestBuilderFactory'
      [ERROR] Errors in 'com/gwtplatform/dispatch/rest/client/DefaultRestRequestBuilderFactory.java'
         [ERROR] Line 144: MediaType cannot be resolved to a variable
         [ERROR] Line 26: The import javax.ws cannot be resolved
         [ERROR] Line 145: HttpHeaders cannot be resolved to a variable
         [ERROR] Line 27: The import javax.ws cannot be resolved
         [ERROR] Line 144: HttpHeaders cannot be resolved to a variable
   Tracing compile failure path for type 'com.github.nmorel.gwtjackson.client.ser.bean.AbstractBeanJsonSerializer'
      [ERROR] Errors in 'com/github/nmorel/gwtjackson/client/ser/bean/AbstractBeanJsonSerializer.java'
         [ERROR] Line 144: PROPERTY cannot be resolved to a variable
         [ERROR] Line 188: The method getInclude() from the type TypeSerializationInfo refers to the missing type As
         [ERROR] Line 172: WRAPPER_ARRAY cannot be resolved to a variable
         [ERROR] Line 157: WRAPPER_OBJECT cannot be resolved to a variable
         [ERROR] Line 143: The method getInclude() from the type TypeSerializationInfo refers to the missing type As
      [ERROR] Errors in 'com/github/nmorel/gwtjackson/client/ser/bean/SubtypeSerializer.java'
         [ERROR] Line 68: The method getInclude() from the type TypeSerializationInfo refers to the missing type As
         [ERROR] Line 69: WRAPPER_OBJECT cannot be resolved to a variable
      [ERROR] Errors in 'com/github/nmorel/gwtjackson/client/ser/bean/TypeSerializationInfo.java'
         [ERROR] Line 34: As cannot be resolved to a type
         [ERROR] Line 22: The import com.fasterxml.jackson.annotation.JsonTypeInfo cannot be resolved
         [ERROR] Line 44: As cannot be resolved to a type
         [ERROR] Line 55: As cannot be resolved to a type
         [ERROR] Line 43: As cannot be resolved to a type
         [ERROR] Line 54: As cannot be resolved to a type
      [ERROR] Errors in 'com/github/nmorel/gwtjackson/client/JsonSerializationContext.java'
         [ERROR] Line 480: ObjectIdGenerator cannot be resolved to a type
         [ERROR] Line 470: ObjectIdGenerator cannot be resolved to a type
         [ERROR] Line 479: ObjectIdGenerator cannot be resolved to a type
         [ERROR] Line 468: ObjectIdGenerator cannot be resolved to a type
         [ERROR] Line 483: ObjectIdGenerator cannot be resolved to a type
         [ERROR] Line 253: ObjectIdGenerator cannot be resolved to a type
         [ERROR] Line 466: ObjectIdGenerator cannot be resolved to a type
         [ERROR] Line 467: ObjectIdGenerator cannot be resolved to a type
         [ERROR] Line 27: The import com.fasterxml.jackson.annotation.ObjectIdGenerator cannot be resolved
         [ERROR] Line 481: ObjectIdGenerator cannot be resolved to a type
      [ERROR] Errors in 'com/github/nmorel/gwtjackson/client/JsonSerializerParameters.java'
         [ERROR] Line 24: The import com.fasterxml.jackson.annotation.JsonInclude cannot be resolved
         [ERROR] Line 140: Include cannot be resolved to a type
         [ERROR] Line 136: Include cannot be resolved to a type
         [ERROR] Line 76: Include cannot be resolved to a type
         [ERROR] Line 76: Include cannot be resolved to a variable
         [ERROR] Line 137: Include cannot be resolved to a type
         [ERROR] Line 141: Include cannot be resolved to a type
   Tracing compile failure path for type 'com.github.nmorel.gwtjackson.client.deser.bean.PropertyIdentityDeserializationInfo'
      [ERROR] Errors in 'com/github/nmorel/gwtjackson/client/deser/bean/PropertyIdentityDeserializationInfo.java'
         [ERROR] Line 4: The import com.fasterxml.jackson.annotation.ObjectIdGenerator cannot be resolved
         [ERROR] Line 45: IdKey cannot be resolved to a type
         [ERROR] Line 46: IdKey cannot be resolved to a type
   Tracing compile failure path for type 'com.github.nmorel.gwtjackson.client.ser.bean.SubtypeSerializer'
      [ERROR] Errors in 'com/github/nmorel/gwtjackson/client/ser/bean/SubtypeSerializer.java'
         [ERROR] Line 68: The method getInclude() from the type TypeSerializationInfo refers to the missing type As
         [ERROR] Line 69: WRAPPER_OBJECT cannot be resolved to a variable
      [ERROR] Errors in 'com/github/nmorel/gwtjackson/client/ser/bean/TypeSerializationInfo.java'
         [ERROR] Line 34: As cannot be resolved to a type
         [ERROR] Line 22: The import com.fasterxml.jackson.annotation.JsonTypeInfo cannot be resolved
         [ERROR] Line 44: As cannot be resolved to a type
         [ERROR] Line 55: As cannot be resolved to a type
         [ERROR] Line 43: As cannot be resolved to a type
         [ERROR] Line 54: As cannot be resolved to a type
      [ERROR] Errors in 'com/github/nmorel/gwtjackson/client/ser/bean/AbstractBeanJsonSerializer.java'
         [ERROR] Line 144: PROPERTY cannot be resolved to a variable
         [ERROR] Line 188: The method getInclude() from the type TypeSerializationInfo refers to the missing type As
         [ERROR] Line 172: WRAPPER_ARRAY cannot be resolved to a variable
         [ERROR] Line 157: WRAPPER_OBJECT cannot be resolved to a variable
         [ERROR] Line 143: The method getInclude() from the type TypeSerializationInfo refers to the missing type As
      [ERROR] Errors in 'com/github/nmorel/gwtjackson/client/JsonSerializationContext.java'
         [ERROR] Line 480: ObjectIdGenerator cannot be resolved to a type
         [ERROR] Line 470: ObjectIdGenerator cannot be resolved to a type
         [ERROR] Line 479: ObjectIdGenerator cannot be resolved to a type
         [ERROR] Line 468: ObjectIdGenerator cannot be resolved to a type
         [ERROR] Line 483: ObjectIdGenerator cannot be resolved to a type
         [ERROR] Line 253: ObjectIdGenerator cannot be resolved to a type
         [ERROR] Line 466: ObjectIdGenerator cannot be resolved to a type
         [ERROR] Line 467: ObjectIdGenerator cannot be resolved to a type
         [ERROR] Line 27: The import com.fasterxml.jackson.annotation.ObjectIdGenerator cannot be resolved
         [ERROR] Line 481: ObjectIdGenerator cannot be resolved to a type
      [ERROR] Errors in 'com/github/nmorel/gwtjackson/client/JsonSerializerParameters.java'
         [ERROR] Line 24: The import com.fasterxml.jackson.annotation.JsonInclude cannot be resolved
         [ERROR] Line 140: Include cannot be resolved to a type
         [ERROR] Line 136: Include cannot be resolved to a type
         [ERROR] Line 76: Include cannot be resolved to a type
         [ERROR] Line 76: Include cannot be resolved to a variable
         [ERROR] Line 137: Include cannot be resolved to a type
         [ERROR] Line 141: Include cannot be resolved to a type
   Tracing compile failure path for type 'com.fasterxml.jackson.annotation.JsonAutoDetect'
      [ERROR] Errors in 'com/github/nmorel/gwtjackson/super/com/fasterxml/jackson/annotation/JsonAutoDetect.java'
         [ERROR] Line 13: JacksonAnnotation cannot be resolved to a type
   Tracing compile failure path for type 'com.github.nmorel.gwtjackson.client.deser.bean.AbstractBeanJsonDeserializer'
      [ERROR] Errors in 'com/github/nmorel/gwtjackson/client/deser/bean/AbstractBeanJsonDeserializer.java'
         [ERROR] Line 225: The method getInclude() from the type TypeDeserializationInfo refers to the missing type As
         [ERROR] Line 370: The method newIdKey(Object) from the type IdentityDeserializationInfo refers to the missing type IdKey
         [ERROR] Line 28: The import com.fasterxml.jackson.annotation.JsonTypeInfo cannot be resolved
         [ERROR] Line 214: WRAPPER_ARRAY cannot be resolved to a variable
         [ERROR] Line 177: PROPERTY cannot be resolved to a variable
         [ERROR] Line 173: The method getInclude() from the type TypeDeserializationInfo refers to the missing type As
         [ERROR] Line 204: WRAPPER_OBJECT cannot be resolved to a variable
         [ERROR] Line 171: As cannot be resolved to a variable
         [ERROR] Line 157: The method newIdKey(Object) from the type IdentityDeserializationInfo refers to the missing type IdKey
         [ERROR] Line 168: As cannot be resolved to a type
   Tracing compile failure path for type 'com.github.nmorel.gwtjackson.client.JsonSerializerParameters'
      [ERROR] Errors in 'com/github/nmorel/gwtjackson/client/JsonSerializerParameters.java'
         [ERROR] Line 24: The import com.fasterxml.jackson.annotation.JsonInclude cannot be resolved
         [ERROR] Line 140: Include cannot be resolved to a type
         [ERROR] Line 136: Include cannot be resolved to a type
         [ERROR] Line 76: Include cannot be resolved to a type
         [ERROR] Line 76: Include cannot be resolved to a variable
         [ERROR] Line 137: Include cannot be resolved to a type
         [ERROR] Line 141: Include cannot be resolved to a type
   Tracing compile failure path for type 'com.github.nmorel.gwtjackson.client.JsonDeserializationContext'
      [ERROR] Errors in 'com/github/nmorel/gwtjackson/client/JsonDeserializationContext.java'
         [ERROR] Line 243: IdKey cannot be resolved to a type
         [ERROR] Line 250: IdKey cannot be resolved to a type
         [ERROR] Line 245: IdKey cannot be resolved to a type
         [ERROR] Line 252: IdKey cannot be resolved to a type
         [ERROR] Line 24: The import com.fasterxml.jackson.annotation.ObjectIdGenerator cannot be resolved
         [ERROR] Line 125: IdKey cannot be resolved to a type
         [ERROR] Line 251: IdKey cannot be resolved to a type
         [ERROR] Line 244: IdKey cannot be resolved to a type
         [ERROR] Line 247: IdKey cannot be resolved to a type
   Tracing compile failure path for type 'com.fasterxml.jackson.annotation.JsonFormat'
      [ERROR] Errors in 'com/github/nmorel/gwtjackson/super/com/fasterxml/jackson/annotation/JsonFormat.java'
         [ERROR] Line 14: JacksonAnnotation cannot be resolved to a type
   Tracing compile failure path for type 'com.github.nmorel.gwtjackson.client.deser.bean.IdentityDeserializationInfo'
      [ERROR] Errors in 'com/github/nmorel/gwtjackson/client/deser/bean/IdentityDeserializationInfo.java'
         [ERROR] Line 45: IdKey cannot be resolved to a type
         [ERROR] Line 19: The import com.fasterxml.jackson.annotation.ObjectIdGenerator cannot be resolved
   Tracing compile failure path for type 'com.github.nmorel.gwtjackson.client.annotation.JsonMixIns'
      [ERROR] Errors in 'com/github/nmorel/gwtjackson/client/annotation/JsonMixIns.java'
         [ERROR] Line 24: The import com.fasterxml.jackson.annotation.JacksonAnnotation cannot be resolved
         [ERROR] Line 42: JacksonAnnotation cannot be resolved to a type
   [ERROR] Aborting compile due to errors in some input files

JSON Inheritance deserialization complex object

I'm having some difficulties parsing this JSON data :

{
    "class":"com.myproject.common.shared.dispatch.GetResult",
    "exceptionMessage":null,
    "payload":{
        "user":{
            "class":"com.myproject.common.shared.business.identity.User",
            "id":3,
            "username":"admin",
            "email":"[email protected]",
            "password":"Test1234",
            "firstName":"Admin",
            "lastName":"Admin",
            "authority":["ROLE_ADMIN","ROLE_USER"]
        },
        "customeUI":{
            "id":1,
            "headerBackgroundColor":"#00699B",
            "headerFontColor":"#ffffff",
            "headerFontHoverColor":"rgb(190, 190, 190)",
            "siderBackgroundColor":"#191919",
            "siderSelectedMenuColor":"#ffffff",
            "siderHoverMenuColor":"#111",
            "siderFontColor":"#ffffff",
            "siderSelectFontColor":"#333",
            "siderMenuBorderTop":"#212121",
            "siderMenuBorderBottom":"#0a0c0e",
            "siderMenuHoverBorderLeft":"#111"
        }
    }
}

Can't deserialize the user property.

The "com.myproject.common.shared.business.identity.User" class is a parent class and have a child class "com.myproject.common.shared.business.identity.BackUser".

Benchmark

Add some kind of benchmark project to compare the performance of different serialization mechanism (piriti, resty, errai).

  • init a project in example
  • deploy it somewhere
  • define a model that all mechanism are able to serialize
  • ....

Serializing some other object in custom serializer

Hello!

I don't find a way how to serialize some other object inside the "doSerialize" method of my custom serializer that extends JsonSerializer.

Let's say I have classes A and B, and A contains field of type B. Now I have custom JSON serializers for both classes A and B and inside AJsonSerializer's doSerialize, I want to write the value of field B.

The thing is, I don't want to write B's fields inside the A's serializer, as in the real life the structure is much more complicated and a class like A contains many other objects. So serializer should be able to delegate each object's writing to its own serializer.

Example:

public class AJsonSerializer extends JsonSerializer {
@OverRide
protected void doSerialize(JsonWriter writer, A value, JsonSerializationContext ctx, JsonSerializerParameters params) {
writer.beginObject();
writer.name("b");
// writer.value(value.getB()); <-- here I want to serialize B with its own custom serializer
writer.endObject();
}
}

Globally disabling getters and setters

Hello!

I our project repository we have thousands of classes, and not all were written conforming to the getter/setter patterns. This was not even required or necessary.

However, gwt-jackson by default processes such non-getter methods that start with "get***". As many such methods are not meant to be used outside of their contexts, they generate an error when called by gwt-jackson.

I know about @JsonAutoDetect. But I don't want to write annotations (or use mixin annotations) for 1000 classes!

Is there a way, to globally configure gwt-jackson for all types, to NEVER process getters and setters, and ONLY use fields?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.