add(new StdDeserializer.NumberDeserializer()); add(new StdDeserializer.BigDecimalDeserializer()); add(new StdDeserializer.BigIntegerDeserializer());
add(new StdDeserializer.NumberDeserializer()); add(new StdDeserializer.BigDecimalDeserializer()); add(new StdDeserializer.BigIntegerDeserializer());
add(new StdDeserializer.NumberDeserializer()); add(new StdDeserializer.BigDecimalDeserializer()); add(new StdDeserializer.BigIntegerDeserializer());
/** * As mentioned in class Javadoc, there is additional complexity in * handling potentially mixed type information here. Because of this, * we must actually check for "raw" integers and doubles first, before * calling type deserializer. */ @Override public Object deserializeWithType(JsonParser jp, DeserializationContext ctxt, TypeDeserializer typeDeserializer) throws IOException, JsonProcessingException { switch (jp.getCurrentToken()) { case VALUE_NUMBER_INT: case VALUE_NUMBER_FLOAT: case VALUE_STRING: // can not point to type information: hence must be non-typed (int/double) return deserialize(jp, ctxt); } return typeDeserializer.deserializeTypedFromScalar(jp, ctxt); } }
/** * As mentioned in class Javadoc, there is additional complexity in * handling potentially mixed type information here. Because of this, * we must actually check for "raw" integers and doubles first, before * calling type deserializer. */ @Override public Object deserializeWithType(JsonParser jp, DeserializationContext ctxt, TypeDeserializer typeDeserializer) throws IOException, JsonProcessingException { switch (jp.getCurrentToken()) { case VALUE_NUMBER_INT: case VALUE_NUMBER_FLOAT: case VALUE_STRING: // can not point to type information: hence must be non-typed (int/double) return deserialize(jp, ctxt); } return typeDeserializer.deserializeTypedFromScalar(jp, ctxt); } }
JacksonNonBlockingObjectMapperFactory factory = new JacksonNonBlockingObjectMapperFactory(); factory.setJsonDeserializers(Arrays.asList(new StdDeserializer[]{ // StdDeserializer, here, comes from Jackson (org.codehaus.jackson.map.deser.StdDeserializer) new StdDeserializer.ShortDeserializer(Short.class, null), new StdDeserializer.IntegerDeserializer(Integer.class, null), new StdDeserializer.CharacterDeserializer(Character.class, null), new StdDeserializer.LongDeserializer(Long.class, null), new StdDeserializer.FloatDeserializer(Float.class, null), new StdDeserializer.DoubleDeserializer(Double.class, null), new StdDeserializer.NumberDeserializer(), new StdDeserializer.BigDecimalDeserializer(), new StdDeserializer.BigIntegerDeserializer(), new StdDeserializer.CalendarDeserializer() })); ObjectMapper om = factory.createObjectMapper();
add(new StdDeserializer.NumberDeserializer()); add(new StdDeserializer.BigDecimalDeserializer()); add(new StdDeserializer.BigIntegerDeserializer());
/** * As mentioned in class Javadoc, there is additional complexity in * handling potentially mixed type information here. Because of this, * we must actually check for "raw" integers and doubles first, before * calling type deserializer. */ @Override public Object deserializeWithType(JsonParser jp, DeserializationContext ctxt, TypeDeserializer typeDeserializer) throws IOException, JsonProcessingException { switch (jp.getCurrentToken()) { case VALUE_NUMBER_INT: case VALUE_NUMBER_FLOAT: case VALUE_STRING: // can not point to type information: hence must be non-typed (int/double) return deserialize(jp, ctxt); } return typeDeserializer.deserializeTypedFromScalar(jp, ctxt); } }
/** * As mentioned in class Javadoc, there is additional complexity in * handling potentially mixed type information here. Because of this, * we must actually check for "raw" integers and doubles first, before * calling type deserializer. */ @Override public Object deserializeWithType(JsonParser jp, DeserializationContext ctxt, TypeDeserializer typeDeserializer) throws IOException, JsonProcessingException { switch (jp.getCurrentToken()) { case VALUE_NUMBER_INT: case VALUE_NUMBER_FLOAT: case VALUE_STRING: // can not point to type information: hence must be non-typed (int/double) return deserialize(jp, ctxt); } return typeDeserializer.deserializeTypedFromScalar(jp, ctxt); } }