Jettison JSON Automatically Changes Data Type
I'm using Resteasy 2.0.1.GA and thusly Resteasy-jettison-provider-1.2.GA and whenever I have a String property that contains 开发者_如何学Pythonall numbers (i.e. String test="1111";), the JSON response will display it as a number by removing the double quotes. If I change it to String test="oneoneoneoneone"; the JSON response will treat it as a String and keep the double quotes in the response. Is there anyway to have the Jettison provider strictly interpret the data to response based on its type and not its value? I tried the below JAXB annotation as well, but I still see the same issue.
@XmlElement(type=String.class)
private String text;
I would recommend switching to using Jackson based provider -- Jettison has enough quirks to make life pretty difficult (and it does not support use of JAXB annotations, even though processing has to go through XML interfaces).
There may be a setting to disable implied conversions (this issue has been mention on jettison user's list) for Jettison; so if you prefer using it, this might be another route.
精彩评论