com.fasterxml.jackson.databind.module.SimpleDeserializers Java Examples
The following examples show how to use
com.fasterxml.jackson.databind.module.SimpleDeserializers.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SchemaSerializationModuleTest.java From data-highway with Apache License 2.0 | 6 votes |
@Test public void setupModule() throws JsonMappingException { SetupContext context = mock(SetupContext.class); underTest.setupModule(context); ArgumentCaptor<SimpleSerializers> serializersCaptor = ArgumentCaptor.forClass(SimpleSerializers.class); ArgumentCaptor<SimpleDeserializers> deserializersCaptor = ArgumentCaptor.forClass(SimpleDeserializers.class); verify(context).addSerializers(serializersCaptor.capture()); verify(context).addDeserializers(deserializersCaptor.capture()); JavaType javaType = new ObjectMapper().constructType(Schema.class); JsonSerializer<?> serializer = serializersCaptor.getValue().findSerializer(null, javaType, null); assertThat(serializer, is(instanceOf(SchemaSerializer.class))); JsonDeserializer<?> deserializer = deserializersCaptor.getValue().findBeanDeserializer(javaType, null, null); assertThat(deserializer, is(instanceOf(SchemaDeserializer.class))); }
Example #2
Source File: CommonObjectMappers.java From titus-control-plane with Apache License 2.0 | 6 votes |
private static ObjectMapper createProtobufMapper() { ObjectMapper mapper = new ObjectMapper(); // Serialization mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); // Deserialization mapper.disable(SerializationFeature.INDENT_OUTPUT); SimpleDeserializers simpleDeserializers = new SimpleDeserializers(); simpleDeserializers.addDeserializer(String.class, new TrimmingStringDeserializer()); List<Deserializers> deserializersList = Arrays.asList( new AssignableFromDeserializers(Message.class, new ProtobufMessageDeserializer()), simpleDeserializers ); CompositeDeserializers compositeDeserializers = new CompositeDeserializers(deserializersList); CustomDeserializerSimpleModule module = new CustomDeserializerSimpleModule(compositeDeserializers); module.addSerializer(Message.class, new ProtobufMessageSerializer()); mapper.registerModule(module); return mapper; }
Example #3
Source File: ProtobufMessageObjectMapperTest.java From titus-control-plane with Apache License 2.0 | 6 votes |
private ObjectMapper getObjectMapper() { ObjectMapper mapper = new ObjectMapper(); // Serialization mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); // Deserialization mapper.disable(SerializationFeature.INDENT_OUTPUT); SimpleDeserializers simpleDeserializers = new SimpleDeserializers(); simpleDeserializers.addDeserializer(String.class, new TrimmingStringDeserializer()); List<Deserializers> deserializersList = Arrays.asList( new AssignableFromDeserializers(Message.class, new ProtobufMessageDeserializer()), simpleDeserializers ); CompositeDeserializers compositeDeserializers = new CompositeDeserializers(deserializersList); CustomDeserializerSimpleModule module = new CustomDeserializerSimpleModule(compositeDeserializers); module.addSerializer(Message.class, new ProtobufMessageSerializer()); mapper.registerModule(module); return mapper; }
Example #4
Source File: MoneyModule.java From jackson-datatype-money with MIT License | 6 votes |
@Override public void setupModule(final SetupContext context) { final SimpleSerializers serializers = new SimpleSerializers(); serializers.addSerializer(CurrencyUnit.class, new CurrencyUnitSerializer()); serializers.addSerializer(MonetaryAmount.class, new MonetaryAmountSerializer(names, writer, formatFactory)); context.addSerializers(serializers); final SimpleDeserializers deserializers = new SimpleDeserializers(); deserializers.addDeserializer(CurrencyUnit.class, new CurrencyUnitDeserializer()); deserializers.addDeserializer(MonetaryAmount.class, new MonetaryAmountDeserializer<>(amountFactory, names)); // for reading into concrete implementation types deserializers.addDeserializer(Money.class, new MonetaryAmountDeserializer<>(moneyFactory, names)); deserializers.addDeserializer(FastMoney.class, new MonetaryAmountDeserializer<>(fastMoneyFactory, names)); deserializers.addDeserializer(RoundedMoney.class, new MonetaryAmountDeserializer<>(roundedMoneyFactory, names)); context.addDeserializers(deserializers); }
Example #5
Source File: ObjectMapperFactoryV2.java From aws-athena-query-federation with Apache License 2.0 | 5 votes |
private StrictObjectMapper(BlockAllocator allocator) { super(JSON_FACTORY); _serializerFactory = SERIALIZER_FACTORY; ImmutableMap<Class<?>, JsonDeserializer<?>> desers = ImmutableMap.of( FederationRequest.class, createRequestDeserializer(allocator), FederationResponse.class, createResponseDeserializer(allocator), LambdaFunctionException.class, new LambdaFunctionExceptionSerDe.Deserializer()); SimpleDeserializers deserializers = new SimpleDeserializers(desers); DeserializerFactoryConfig dConfig = new DeserializerFactoryConfig().withAdditionalDeserializers(deserializers); _deserializationContext = new DefaultDeserializationContext.Impl(new StrictDeserializerFactory(dConfig)); // required by LambdaInvokerFactory disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); }
Example #6
Source File: SortJacksonModule.java From spring-cloud-openfeign with Apache License 2.0 | 5 votes |
@Override public void setupModule(SetupContext context) { SimpleSerializers serializers = new SimpleSerializers(); serializers.addSerializer(Sort.class, new SortJsonComponent.SortSerializer()); context.addSerializers(serializers); SimpleDeserializers deserializers = new SimpleDeserializers(); deserializers.addDeserializer(Sort.class, new SortJsonComponent.SortDeserializer()); context.addDeserializers(deserializers); }
Example #7
Source File: JobJacksonModule.java From haven-platform with Apache License 2.0 | 5 votes |
@Override public void setupModule(SetupContext setupContext) { SimpleSerializers serializers = new SimpleSerializers(); addSerializers(serializers); setupContext.addSerializers(serializers); SimpleDeserializers deserializers = new SimpleDeserializers(); addDeserializers(deserializers); setupContext.addDeserializers(deserializers); }
Example #8
Source File: DmJacksonModule.java From haven-platform with Apache License 2.0 | 5 votes |
/** * Method called by {@link ObjectMapper} when module is registered. * It is called to let module register functionality it provides, * using callback methods passed-in context object exposes. */ @Override public void setupModule(SetupContext setupContext) { SimpleSerializers serializers = new SimpleSerializers(); addSerializers(serializers); setupContext.addSerializers(serializers); SimpleDeserializers deserializers = new SimpleDeserializers(); addDeserializers(deserializers); setupContext.addDeserializers(deserializers); setupContext.addBeanDeserializerModifier(new KeeperBeanDeserializerModifier()); }
Example #9
Source File: RosettaObjectMapperTest.java From Rosetta with Apache License 2.0 | 5 votes |
private static void registerDeserializer(ConfigRegistry config, JsonDeserializer<TestObject> deserializer) { ObjectMapper objectMapper = new ObjectMapper(); SimpleModule module = new SimpleModule(); module.setDeserializers(new SimpleDeserializers(Collections.singletonMap(TestObject.class, deserializer))); objectMapper.registerModule(module); config.get(RosettaObjectMapper.class).setObjectMapper(objectMapper); }
Example #10
Source File: SchemaSerializationModule.java From data-highway with Apache License 2.0 | 4 votes |
@Override public void setupModule(SetupContext context) { context.addSerializers(new SimpleSerializers(Collections.singletonList(new SchemaSerializer()))); context.addDeserializers(new SimpleDeserializers(Collections.singletonMap(Schema.class, new SchemaDeserializer()))); }
Example #11
Source File: JobJacksonModule.java From haven-platform with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") private void addDeserializers(SimpleDeserializers deserializers) { }
Example #12
Source File: DmJacksonModule.java From haven-platform with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") private void addDeserializers(SimpleDeserializers deserializers) { deserializers.addDeserializer(MimeType.class, new MimeTypeDeserializer()); deserializers.addDeserializer(Keeper.class, (JsonDeserializer) new KeeperDeserializer()); }
Example #13
Source File: ProtobufModule.java From jackson-datatype-protobuf with Apache License 2.0 | 4 votes |
@Override public void setupModule(SetupContext context) { SimpleSerializers serializers = new SimpleSerializers(); serializers.addSerializer(new MessageSerializer(config)); serializers.addSerializer(new DurationSerializer()); serializers.addSerializer(new FieldMaskSerializer()); serializers.addSerializer(new ListValueSerializer()); serializers.addSerializer(new NullValueSerializer()); serializers.addSerializer(new StructSerializer()); serializers.addSerializer(new TimestampSerializer()); serializers.addSerializer(new ValueSerializer()); serializers.addSerializer(new WrappedPrimitiveSerializer<>(DoubleValue.class)); serializers.addSerializer(new WrappedPrimitiveSerializer<>(FloatValue.class)); serializers.addSerializer(new WrappedPrimitiveSerializer<>(Int64Value.class)); serializers.addSerializer(new WrappedPrimitiveSerializer<>(UInt64Value.class)); serializers.addSerializer(new WrappedPrimitiveSerializer<>(Int32Value.class)); serializers.addSerializer(new WrappedPrimitiveSerializer<>(UInt32Value.class)); serializers.addSerializer(new WrappedPrimitiveSerializer<>(BoolValue.class)); serializers.addSerializer(new WrappedPrimitiveSerializer<>(StringValue.class)); serializers.addSerializer(new WrappedPrimitiveSerializer<>(BytesValue.class)); context.addSerializers(serializers); context.addDeserializers(new MessageDeserializerFactory(config)); SimpleDeserializers deserializers = new SimpleDeserializers(); deserializers.addDeserializer(Duration.class, new DurationDeserializer()); deserializers.addDeserializer(FieldMask.class, new FieldMaskDeserializer()); deserializers.addDeserializer(ListValue.class, new ListValueDeserializer().buildAtEnd()); deserializers.addDeserializer(NullValue.class, new NullValueDeserializer()); deserializers.addDeserializer(Struct.class, new StructDeserializer().buildAtEnd()); deserializers.addDeserializer(Timestamp.class, new TimestampDeserializer()); deserializers.addDeserializer(Value.class, new ValueDeserializer().buildAtEnd()); deserializers.addDeserializer(DoubleValue.class, wrappedPrimitiveDeserializer(DoubleValue.class)); deserializers.addDeserializer(FloatValue.class, wrappedPrimitiveDeserializer(FloatValue.class)); deserializers.addDeserializer(Int64Value.class, wrappedPrimitiveDeserializer(Int64Value.class)); deserializers.addDeserializer(UInt64Value.class, wrappedPrimitiveDeserializer(UInt64Value.class)); deserializers.addDeserializer(Int32Value.class, wrappedPrimitiveDeserializer(Int32Value.class)); deserializers.addDeserializer(UInt32Value.class, wrappedPrimitiveDeserializer(UInt32Value.class)); deserializers.addDeserializer(BoolValue.class, wrappedPrimitiveDeserializer(BoolValue.class)); deserializers.addDeserializer(StringValue.class, wrappedPrimitiveDeserializer(StringValue.class)); deserializers.addDeserializer(BytesValue.class, wrappedPrimitiveDeserializer(BytesValue.class)); context.addDeserializers(deserializers); context.setMixInAnnotations(MessageOrBuilder.class, MessageOrBuilderMixin.class); }