tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Romain Manni-Bucau <rmannibu...@gmail.com>
Subject Re: @JohnzonProperty
Date Wed, 01 Jun 2016 09:07:46 GMT
Hello,

setAccessMode("field") I guess (or "both") on the builder. Default is POJO
convention so only reads annotations on getter and setters.

Using ATM:

new MapperBuilder().setAccessModeName("field").build();


With:

@Data public class OAuth2Token {
@JohnzonProperty("access_token")
private String accessToken;
@JohnzonProperty("refresh_token")
private String refreshToken;
@JohnzonProperty("expires_in")
private long expiresIn; }

Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com> | JavaEE Factory
<https://javaeefactory-rmannibucau.rhcloud.com>

2016-06-01 10:13 GMT+02:00 hwaastad <helge@waastad.org>:

> Hi,
> I might be missing something but:
>
>
> public class TokenResponse {
>
>     @JohnzonProperty("token_type")
>     private String tokenType;
>     @JohnzonProperty("mapi")
>     private String mapi;
>     @JohnzonProperty("access_token")
>     private String accessToken;
>     @JohnzonProperty("expires_in")
>     private Integer expiresIn;
>
>     ..constructs and getters setters
> }
>
> and this test is failing on readObject:
>
> final Mapper build = new MapperBuilder().setPretty(true).build();
> String response =
>
> "{\"access_token\":\"muz7bkezs6bfk6ea4vaz97de\",\"token_type\":\"bearer\",\"expires_in\":3600}";
>         String response2 =
>
> "{\"accessToken\":\"muz7bkezs6bfk6ea4vaz97de\",\"tokenType\":\"bearer\",\"expiresIn\":3600}";
>         TokenResponse readObject = build.readObject(response,
> TokenResponse.class);
>         TokenResponse readObject2 = build.readObject(response2,
> TokenResponse.class);
>         assertNotNull(readObject.getAccessToken());
>         assertNotNull(readObject2.getAccessToken());
>
>
> /hw
>
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/JohnzonProperty-tp4678709.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message