[ 
https://issues.apache.org/jira/browse/JOHNZON-88?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15360237#comment-15360237
 ] 

Jerome Doby commented on JOHNZON-88:
------------------------------------

And one last thing, you may want to update your documentation as this is what 
is outlined on the site:

{code}
@JohnzonProperty

Sometimes the json name is not java friendly (_foo or foo-bar or even 200 for 
instance). For that cases @JohnzonProperty allows to customize the name used:

public class MyModel {
  @JohnzonProperty("__date")
  private LocalDate date;
  
  // getters/setters
}
{code}

> Johnzon does not process Johnzon annotations when hydrating models using 
> javax.ws.rs.client.Client
> --------------------------------------------------------------------------------------------------
>
>                 Key: JOHNZON-88
>                 URL: https://issues.apache.org/jira/browse/JOHNZON-88
>             Project: Johnzon
>          Issue Type: Improvement
>          Components: JAX-RS
>    Affects Versions: 0.9.3-incubating
>         Environment: Server version: Apache Tomcat (TomEE)/8.5.2 (7.0.0)
> Server built: May 11 2016 21:49:07 UTC
> Server number: 8.5.2.0
> OS Name: Windows 10
> OS Version: 10.0
> Architecture: amd64
> Java Home:  C:\Program Files\Java\home\jre
> JVM Version: 1.8.0_73-b02
> JVM Vendor: Oracle Corporation
>            Reporter: Jerome Doby
>            Priority: Minor
>
> According to the documentation at http://johnzon.apache.org/index.html, 
> Johnzon is the default provider on TomEE 7.X, but it does not seem to process 
> any Johnzon annotations when hydrating JSON responses using the default 
> javax.ws.rs.client.Client implementation.
> Example:
> {code:title=Search.java|borderStyle=solid}
> package mypackage.models;
> import org.apache.johnzon.mapper.JohnzonProperty;
> public class Search
> {
>     private Integer page;
>     @JohnzonProperty( "total_pages" )
>     private Integer totalPages;
>     public Integer getPage()
>     {
>         return page;
>     }
>     public void setPage( Integer page )
>     {
>         this.page = page;
>     }
>     public Integer getTotalPages()
>     {
>         return totalPages;
>     }
>     public void setTotalPages( Integer totalPages )
>     {
>         this.totalPages = totalPages;
>     }
> }
> {code}
> {code:title=Bootstrap.java|borderStyle=solid}
> package mypackage;
> import mypackage.models.Search;
> import javax.annotation.PostConstruct;
> import javax.ejb.Singleton;
> import javax.ejb.Startup;
> import javax.ws.rs.client.Client;
> import javax.ws.rs.client.ClientBuilder;
> @Singleton
> @Startup
> public class Bootstrap
> {
>     private Client client;
>     @PostConstruct
>     private void postConstruct()
>     {
>         client = ClientBuilder.newClient();
>         Search search = client.target( "http://someurl.json"; )
>                               .request()
>                               .get( Search.class );
>     }
> }
> {code}
> {code:title=Response.json|borderStyle=solid}
> {
>       "page": 1,
>       "total_pages": 114
> }
> {code}
> In this case, the field totalPages is null, but I would expect it to be 114. 
> Is there something that I need to do to activate this behaviour? If so, can 
> you add this information to the documentation?



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to