tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jonathan S Fisher (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (TOMEE-2232) TomEE doesn't honor @XMLElement() name when deserializing JSON
Date Sat, 08 Sep 2018 16:02:00 GMT

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

Jonathan S Fisher commented on TOMEE-2232:
------------------------------------------

I'm not sure what you said; perhaps you could rephrase more clearly.

For anyone else that's facing this issue, I have a patch to replace Johnzon with Moxy, which
works correctly and fixes a multitude of other bugs. Feel free to get ahold of me via any
of my social media accounts (@exabrial) for it.

> TomEE doesn't honor @XMLElement() name when deserializing JSON
> --------------------------------------------------------------
>
>                 Key: TOMEE-2232
>                 URL: https://issues.apache.org/jira/browse/TOMEE-2232
>             Project: TomEE
>          Issue Type: Bug
>    Affects Versions: 7.0.5
>            Reporter: Jonathan S Fisher
>            Priority: Critical
>
> We encountered a strange limitation while working with salesforce. We're hitting their
login OAUTH endpoint and it returns a JSON string like this:
> {code:json}
> {  
>    "access_token":"onebiglongstring",
>    "instance_url":"https://ab67.salesforce.com",
>    "id":"https://test.salesforce.com/id/sfid/sifd",
>    "token_type":"Bearer",
>    "issued_at":"1536415016572",
>    "signature":"morebase64"
> }
>  {code}
> So naturally we constructed the following Java class:
> {code:java}
> @Data
> public class SalesforceLoginToken {
> 	@XmlElement(name = "access_token")
> 	private String accessToken;
> 	@XmlElement(name = "instance_url")
> 	private String instanceUrl;
> 	@XmlElement
> 	private String id;
> 	@XmlElement(name = "token_type")
> 	private String tokenType;
> 	@XmlElement(name = "issued_at")
> 	private String issuedAt;
> 	@XmlElement
> 	private String signature;
> }
> {code}
> However, TomEE will not deserialize any of the fields where the name is specified in
the XMLElement. A [head-desking] workaround we're using is to break javabean convention and
write our variables like this:
> {code:java}
> 	@XmlElement
> 	private String token_type;
> {code}
> because this won't work. TomEE simply fills out null every time:
> {code:java}
> 	@XmlElement(name = "token_type")
> 	private String tokenType;
> {code}
> I believe this used to work in TomEE 1.7.5, I haven't tested on master or anything else.
> Anyway thanks,
> -Jonathan



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message