Jettison JSON automatically changes data type

I use Resteasy 2.0.1.GA and therefore Resteasy-jettison-provider-1.2.GA and whenever I have a String property that contains all numbers (like String test = "1111";), JSON response will display it as a number by removing double quotes. If I change it to String test = "oneoneoneoneone"; the JSON response will treat it as a string and store double quotes in the response. Is there anyway for the Jettison provider to strictly interpret the response data based on its type and not its value? I also tried the annotation below JAXB, but I still see the same problem.

@XmlElement(type=String.class) private String text; 
+4
source share
1 answer

I would recommend switching to using the Jackson provider - Jettison has enough quirks to make life quite complicated (and it does not support the use of JAXB annotations, although processing must go through XML interfaces).

There may be a setting to disable forbidden conversions (this problem is mentioned in the list of reset users) for Jettison; therefore, if you prefer to use it, this may be a different route.

+1
source

Source: https://habr.com/ru/post/1340844/


All Articles