Reputation: 111
Recently i use restlet to publish some info as web service. Same code host in jetty server, but in different server i got 2 version result.
I think when i call webservice "http://.....api/currencies.json" it will use jackson extension to convert result to json format, but i don't know why got different version.
Is anybody can help me to figure out the problem, thanks!
This is the code, and i use restlet extension: json, xml, jackson, xstream.
@Get("json|xml")
public List<CurrencyInfoDTO> represent() {
return ...;
}
@XStreamAlias("currency")
public class CurrencyInfoDTO {
protected String code;
protected String sign;
....
}
Output version 1:
{
"list": [
{
"currency": [
{
"code": "CNY",
"sign": "¥",
"rate": 1
},
{
"code": "HKD",
"sign": "HK$",
"rate": 0.8145
},
]
}
]
}
Output version 2:
[
{
"code": "CNY",
"sign": "¥",
"rate": 1
},
{
"code": "HKD",
"sign": "HK$",
"rate": 0.8145
}
]
The server for version 1 is host in amazon aws, and server for version 2 is my local machine for development.
What i think is the version 1 is output as an object and version 2 is output as array.
And i try to remove jackson extension in my local machine, it will output as version 1, so i guess version 1 is using xstream extension, and version 2 is using jackson extension, but why restlet use different extension to handle same method output?
Thanks a lot! Rick
Upvotes: 2
Views: 602
Reputation: 2892
The relative position of the Restlet extensions in the classpath matters. Trying putting org.restlet.ext.jackson JAR before org.restlet.ext.xstream one.
If using a WAR, you can also manually adjust the converter helpers order in the Restlet engine.
Upvotes: 2