public JsonSchemaSerializer() { objectMapper = new ObjectMapper(); SimpleDeserializers simpleDeserializers = new SimpleDeserializers(); simpleDeserializers.addDeserializer(String.class, new StringDeserializer()); objectMapper.setDeserializerProvider( new StdDeserializerProvider().withAdditionalDeserializers(simpleDeserializers)); }
@Before public void setUp(){ mapper = new ObjectMapper(); SimpleDeserializers deserializers = new SimpleDeserializers(); deserializers.addDeserializer(Map.class, new StripeObjectDeserializer()); mapper.setDeserializerProvider(new StdDeserializerProvider().withAdditionalDeserializers(deserializers)); }
/** * * @param jf JsonFactory to use: if null, a new {@link MappingJsonFactory} will be constructed * @param sp SerializerProvider to use: if null, a {@link StdSerializerProvider} will be constructed * @param dp DeserializerProvider to use: if null, a {@link StdDeserializerProvider} will be constructed * @param sconfig Serialization configuration to use; if null, basic {@link SerializationConfig} * will be constructed * @param dconfig Deserialization configuration to use; if null, basic {@link DeserializationConfig} * will be constructed */ public ObjectMapper(JsonFactory jf, SerializerProvider sp, DeserializerProvider dp, SerializationConfig sconfig, DeserializationConfig dconfig) { /* 02-Mar-2009, tatu: Important: we MUST default to using * the mapping factory, otherwise tree serialization will * have problems with POJONodes. * 03-Jan-2010, tatu: and obviously we also must pass 'this', * to create actual linking. */ _jsonFactory = (jf == null) ? new MappingJsonFactory(this) : jf; // visibility checker; usually default _visibilityChecker = STD_VISIBILITY_CHECKER; _serializationConfig = (sconfig != null) ? sconfig : new SerializationConfig(DEFAULT_INTROSPECTOR, DEFAULT_ANNOTATION_INTROSPECTOR, _visibilityChecker); _deserializationConfig = (dconfig != null) ? dconfig : new DeserializationConfig(DEFAULT_INTROSPECTOR, DEFAULT_ANNOTATION_INTROSPECTOR, _visibilityChecker); _serializerProvider = (sp == null) ? new StdSerializerProvider() : sp; _deserializerProvider = (dp == null) ? new StdDeserializerProvider() : dp; // Default serializer factory is stateless, can just assign _serializerFactory = BeanSerializerFactory.instance; // and use standard JsonNodeFactory initially _nodeFactory = JsonNodeFactory.instance; }
public static ObjectMapper createCustomMapper() { ObjectMapper result = new ObjectMapper(); CustomDeserializerFactory deserializerFactory = new CustomDeserializerFactory(); deserializerFactory.addSpecificMapping(Configuration.class, new ConfigurationDeserializer()); deserializerFactory.addSpecificMapping(CounterMap.class, new CounterDeserializer()); result.setDeserializerProvider(new StdDeserializerProvider(deserializerFactory)); return result; }
public ObjectMapper toObjectMapper() { final CustomDeserializerFactory factory = createFactory(); final DeserializerProvider deserializerProvider = new StdDeserializerProvider(factory); final ObjectMapper mapper = new ObjectMapper(); mapper.setDeserializerProvider(deserializerProvider); return mapper; }