You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by "Jonathan S Fisher (JIRA)" <ji...@apache.org> on 2018/09/08 14:20:00 UTC
[jira] [Updated] (TOMEE-2232) TomEE doesn't honor @XMLElement()
name when deserializing JSON
[ https://issues.apache.org/jira/browse/TOMEE-2232?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Jonathan S Fisher updated TOMEE-2232:
-------------------------------------
Description:
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
was:
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 value 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
Summary: TomEE doesn't honor @XMLElement() name when deserializing JSON (was: TomEE doesn't honor @XMLElement() valuss when deserializing JSON)
> 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)