users@jersey.java.net

[Jersey] In JSON output how do you write a number as a number and not as a string?

From: nbaliga <nbaliga_at_cleartrial.com>
Date: Thu, 16 Feb 2012 13:26:24 -0800 (PST)

I upgraded to Jackson 1.9.

I am using Jersey 1.5.

I have set up a Provider to provide a Jackson ObjectMapper instance that I
have configured with the following property:

/
@Component
@Provider
public class JacksonObjectMapperProvider
      implements ContextResolver<ObjectMapper>
{
objectMapper.configure( JsonGenerator.Feature.WRITE_NUMBERS_AS_STRINGS,
false );
...
}
/

I have also set up the initParam enabling the POJOMappingFeature in my
web.xml

I am now noticing that numbers are being serialized in JSON, with quotes.

I tried a test case using the same ObjectMapper provider and the numbers get
serialized without any quotes.

This implies that Jackson is doing what it's supposed to when used on it's
own, but somehow the Jersey + Jackson combination is causing numbers to be
quoted.

Any clues?

--
View this message in context: http://jersey.576304.n2.nabble.com/In-JSON-output-how-do-you-write-a-number-as-a-number-and-not-as-a-string-tp7292424p7292424.html
Sent from the Jersey mailing list archive at Nabble.com.