I am trying to go from XSD->POJO->JSON for use with UPS tracking API which is case sensitive. I'm using Jackson 2.6.7 In the generated JSON. I am seeing camel case names when I should see below:
"TrackRequest": {
"InquiryNumber": "1Z12345E6205277936"
}
The generated Java bean is annotated like so:
@XmlElement(name = "TrackRequest")
protected TrackRequest trackRequest;
I've tried a few mapping feature settings such as USE_WRAPPER_NAME_AS_PROPERTY_NAME and USE_STD_BEAN_NAMING which don't appear to have the desired result.
I'm generating the JSON like so:
ObjectMapper mapper = new ObjectMapper();
String jsonRequest = mapper.writeValueAsString(upsRequest);
The upsRequest bean looks like this:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"upsSecurity",
"trackRequest"
})
@XmlRootElement(name = "Request")
public class Request {
@XmlElement(name = "UPSSecurity")
protected UPSSecurity upsSecurity;
@XmlElement(name = "TrackRequest")
protected TrackRequest trackRequest;
/**
* Gets the value of the upsSecurity property.
*
* @return
* possible object is
* {@link UPSSecurity }
*
*/
public UPSSecurity getUPSSecurity() {
return upsSecurity;
}
/**
* Sets the value of the upsSecurity property.
*
* @param value
* allowed object is
* {@link UPSSecurity }
*
*/
public void setUPSSecurity(UPSSecurity value) {
this.upsSecurity = value;
}
/**
* Gets the value of the trackRequest property.
*
* @return
* possible object is
* {@link TrackRequest }
*
*/
public TrackRequest getTrackRequest() {
return trackRequest;
}
/**
* Sets the value of the trackRequest property.
*
* @param value
* allowed object is
* {@link TrackRequest }
*
*/
public void setTrackRequest(TrackRequest value) {
this.trackRequest = value;
}
}
According to the docs, I should be getting the desired output unless I'm missing something
@JsonProperty("TrackRequest")
. If it doesn't work on the field, try on the getter method instead. – Parmenides