Reputation: 351
So, I have started using Jersey as the implementation of JAX-RS in our application for REST services and I came across a strange issue with it. We have been provided with a standard response as below:
"Outer":
{
"agencyPercentagePayment": "80",
"agencyProviderPaymentAmount": "140.00",
"benCoDtls":
{
"benCode": "String1",
"fullName": "String2",
"id": "String3",
"title": "String4"
},
"levelOfCare": "Full-Time",
"paymentDate": "2014-02-19T15:20",
"titleInfo":
{
"benAmt": "140.0",
"benDesc": "AAAA",
"subTitle": "aaaa",
"title": "String"
},
"units": "10"
}
However, The JSON generated by the Jersey provider generates an arbitary response as below:
"Outer":
{
"agencyProviderPaymentAmount": "140.00",
"benCoDtls":
{
"benCode": "String1",
"fullName": "String2",
"id": "String3",
"title": "String4"
},
"agencyPercentagePayment": "80",
"titleInfo":
{
"benAmt": "140.0",
"benDesc": "AAAA",
"subTitle": "aaaa",
"title": "String"
},
"paymentDate": "2014-02-19T15:20",
"levelOfCare": "Full-Time",
"units": "10"
}
As seen above the response expects agencyPercentagePayment to be first element of Outer levelOfCare as first element after completion of benCoDtls array and paymentDate after levelOfCare, however the response is different as you see.
Any suggestions how to enforce the response generated by the Jersey Jackson Providers? I can share the Java class if required.
Thanks
Upvotes: 0
Views: 172
Reputation: 766
You should be able to fix this using @XmlType
annotation:
@XmlType(propOrder={"agencyPercentagePayment", "agencyProviderPaymentAmount" , ... })
@XmlRootElement
public class Outer {
....
}
Upvotes: 2