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

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

Hm, I've figured out how to use the AccessMode:

{code}
    @PostConstruct
    private void postConstruct()
    {
        client = ClientBuilder.newClient();
        String search = client.target( "http://json.json"; )
                              .request( MediaType.APPLICATION_JSON )
                              .get( String.class );
        Mapper mapper = new MapperBuilder().setAccessMode( new FieldAccessMode( 
false, false ) ).build();
        Search s = mapper.readObject( search, Search.class );
    }
{code}

However it required me to actually use the Mapper class manually. This works, 
but is there a way to set this up during the building of the request?

> 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