title: Jersey client read json response into custom object
body: <pre><code>public class RESTDataServiceClient{    
      private Client client;
      private String dataServiceUri;
      private String dataServiceResource;    
      private CustomData customData;
  
      public RESTDataServiceClient(String dataServiceUri, String dataServiceResource, Client client){
          this.client = client;
          this.dataServiceUri = dataServiceUri;
          this.dataServiceResource = dataServiceResource;
      }
  
      @Override
      public CustomData getCustomData() {
          WebTarget dataServiceTarget = client.target(dataServiceUri).path(dataServiceResource);
          Invocation.Builder invocationBuilder = dataServiceTarget.request(MediaType.APPLICATION_JSON_TYPE);
          Response response = invocationBuilder.get();
          myCustomData = response.readEntity(CustomData.class);
          return myCustomData;
      }
  }
  
  CustomData.java
  public class CustomData{
          private TLongObjectMap&lt;Map&lt;String, TIntIntMap&gt;&gt; data;
          public CustomData() {
              this.data = new TLongObjectHashMap&lt;&gt;();
      }
      //getter and setter
  }
  </code></pre>
  
  <p>sample json content</p>
  
  <pre><code> {"50000":{"testString":{"1":10}},"50001":{"testString1":{"2":11}} }
  </code></pre>
  
  <p>I am trying to get data from a data service which is going to return data in a JSON format. I am trying to write a client to read that JSON into a custom object. The CustomData contains a nested trove map datastructure. we wrote a custom serializer for that and the server part works fine. I am unable to get the rest client read the data into an object, but reading into string works. I tried above pasted code with the sample data and i get the error below.</p>
  
  <pre><code>javax.ws.rs.ProcessingException: Error reading entity from input stream.
      at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:866)
      at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:783)
      at org.glassfish.jersey.client.ClientResponse.readEntity(ClientResponse.java:326)
      at org.glassfish.jersey.client.InboundJaxrsResponse$1.call(InboundJaxrsResponse.java:111)
      at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
      at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
      at org.glassfish.jersey.internal.Errors.process(Errors.java:228)
      at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:399)
      at org.glassfish.jersey.client.InboundJaxrsResponse.readEntity(InboundJaxrsResponse.java:108)
      at com.sample.data.RESTDataServiceClient.getCustomData(RESTDataServiceClient.java:42)
  
  Caused by: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "50000" (class com.sample.data.CustomData), not marked as ignorable (0 known properties: ])
   at [Source: org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream@2cb89281; line: 1, column: 14] (through reference chain: com.sample.data.CustomData["50000"])
      at com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:51)
      at com.fasterxml.jackson.databind.DeserializationContext.reportUnknownProperty(DeserializationContext.java:671)
      at com.fasterxml.jackson.databind.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:773)
      at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownProperty(BeanDeserializerBase.java:1297)
      at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownVanilla(BeanDeserializerBase.java:1275)
      at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:247)
      at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:118)
      at com.fasterxml.jackson.databind.ObjectReader._bind(ObjectReader.java:1233)
      at com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:677)
      at com.fasterxml.jackson.jaxrs.base.ProviderBase.readFrom(ProviderBase.java:777)
      at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.invokeReadFrom(ReaderInterceptorExecutor.java:264)
      at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.aroundReadFrom(ReaderInterceptorExecutor.java:234)
      at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor.proceed(ReaderInterceptorExecutor.java:154)
      at org.glassfish.jersey.message.internal.MessageBodyFactory.readFrom(MessageBodyFactory.java:1124)
      at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:851)
      ... 38 more
  </code></pre>