Refine search
protected void init(ObjectMapper objectMapper) { SimpleModule module = new SimpleModule(); module.setSerializerModifier(modifier); module.addDeserializer(Event.class, eventDeserializer); module.addDeserializer(AckArgs.class, ackArgsDeserializer); objectMapper.registerModule(module); objectMapper.setSerializationInclusion(Include.NON_NULL); objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); objectMapper.configure(SerializationFeature.WRITE_BIGDECIMAL_AS_PLAIN, true); objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); }
public static SimpleModule getModule() { SimpleModule module = new SimpleModule(); module.addDeserializer(CloseableIterable.class, new CloseableIterableDeserializer()); return module; }
LongJsonDeserializer deserializer = new LongJsonDeserializer(); SimpleModule module = new SimpleModule("LongDeserializerModule", new Version(1, 0, 0, null)); module.addDeserializer(Long.class, deserializer); ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(module);
private void addDeserializers(ObjectMapper mapper) { SimpleModule module = new SimpleModule(); ObjectReader reader = mapper.reader(); module.addDeserializer(Payload.class, new PayloadDeserializer(reader)); module.addDeserializer(Header.class, new HeaderDeserializer(reader)); mapper.registerModule(module); }
public static void configure(ObjectMapperModule mapper) { SimpleModule module = new SimpleModule(); module.addSerializer(Timestamp.class, new DateTimeZoneSerializer()); module.addDeserializer(Timestamp.class, new DateTimeZoneDeserializer()); mapper.registerModule(module); }
new SimpleModule("LongDeserializerModule", new Version(1, 0, 0, null)); module.addDeserializer(Long.class, new LongJsonDeserializer()); mapper.registerModule(module);
private static ObjectMapper getMapper() { if (mapper == null) { mapper = new ObjectMapper(); SimpleModule module = new SimpleModule(); module.addDeserializer(RowMap.class, new RowMapDeserializer()); mapper.registerModule(module); } return mapper; }
/** Create a module including the serializer and deserializer for local dates */ public static SimpleModule makeModule () { Version moduleVersion = new Version(1, 0, 0, null, null, null); SimpleModule module = new SimpleModule("LocalDate", moduleVersion); module.addSerializer(LocalDate.class, new JodaLocalDateSerializer()); module.addDeserializer(LocalDate.class, new JodaLocalDateDeserializer()); return module; }
@Test public void testFromJsonWithLog4jModule() throws Exception { final ObjectMapper mapper = new ObjectMapper(); final boolean encodeThreadContextAsList = false; final SimpleModule module = new Log4jJsonModule(encodeThreadContextAsList, true, false, false); module.addDeserializer(StackTraceElement.class, new Log4jStackTraceElementDeserializer()); mapper.registerModule(module); final StackTraceElement expected = new StackTraceElement("package.SomeClass", "someMethod", "SomeClass.java", 123); final String s = this.aposToQuotes("{'class':'package.SomeClass','method':'someMethod','file':'SomeClass.java','line':123}"); final StackTraceElement actual = mapper.readValue(s, StackTraceElement.class); Assert.assertEquals(expected, actual); } }
private static ObjectMapper getMapper(String secret_key) { if (mapper == null) { mapper = new ObjectMapper(); SimpleModule module = new SimpleModule(); module.addDeserializer(RowMap.class, new RowMapDeserializer(secret_key)); mapper.registerModule(module); } return mapper; }
/** Create a module including the serializer and deserializer for qualified mode sets */ public static SimpleModule makeModule () { Version moduleVersion = new Version(1, 0, 0, null, null, null); SimpleModule module = new SimpleModule("QualifiedModeSet", moduleVersion); module.addSerializer(QualifiedModeSet.class, new QualifiedModeSetSerializer()); module.addDeserializer(QualifiedModeSet.class, new QualifiedModeSetDeserializer()); return module; } }
@Override public CoinMarketCapArrayData<CoinMarketCapTicker> deserialize( JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { ObjectCodec oc = jp.getCodec(); JsonNode node = oc.readTree(jp); if (node.isObject()) { List<CoinMarketCapTicker> tickers = new LinkedList<>(); ObjectMapper mapper = new ObjectMapper(); SimpleModule module = new SimpleModule(); module.addDeserializer( CoinMarketCapTicker.class, new CoinMarketCapTicker.CoinMarketCapTickerDeserializer()); mapper.registerModule(module); for (JsonNode child : node.get("data")) { tickers.add(mapper.treeToValue(child, CoinMarketCapTicker.class)); } return new CoinMarketCapArrayData<>(tickers); } return null; } }
public static void configure(ObjectMapperModule mapper) { SimpleModule module = new SimpleModule(); module.addSerializer(Charset.class, new CharsetSerializer()); module.addDeserializer(Charset.class, new CharsetDeserializer()); mapper.registerModule(module); }
@Override public void configureObjectMapper(ObjectMapper mapper) { super.configureObjectMapper(mapper); final SimpleModule customDeserializer = new SimpleModule(TrueFxTicker.class.getSimpleName(), Version.unknownVersion()); customDeserializer.addDeserializer( TrueFxTicker.class, new TrueFxTicker.TrueFxTickerDeserializer()); mapper.registerModule(customDeserializer); } };
public static void configure(ObjectMapperModule mapper) { SimpleModule module = new SimpleModule(); module.addSerializer(LocalFile.class, new LocalFileSerializer()); module.addDeserializer(LocalFile.class, new LocalFileDeserializer()); mapper.registerModule(module); }
protected ObjectMapper createObjectMapper() { ObjectMapper mapper = new ObjectMapper(); mapper.setPropertyNamingStrategy(new ConfigPropertyNamingStrategy()); mapper.enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS); mapper.enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES); mapper.configure(JsonParser.Feature.ALLOW_COMMENTS, true); mapper.configure(JsonParser.Feature.ALLOW_YAML_COMMENTS, true); SimpleModule module = new SimpleModule("PolymorphicTypes"); module.addDeserializer(PartitionGroupConfig.class, new PartitionGroupDeserializer(atomix.getRegistry())); module.addDeserializer(PrimitiveProtocolConfig.class, new PrimitiveProtocolDeserializer(atomix.getRegistry())); module.addDeserializer(PrimitiveConfig.class, new PrimitiveConfigDeserializer(atomix.getRegistry())); mapper.registerModule(module); return mapper; }
/** Create a module including the serializer and deserializer for local dates */ public static SimpleModule makeModule () { Version moduleVersion = new Version(1, 0, 0, null, null, null); SimpleModule module = new SimpleModule("TraverseModeSet", moduleVersion); module.addSerializer(TraverseModeSet.class, new TraverseModeSetSerializer()); module.addDeserializer(TraverseModeSet.class, new TraverseModeSetDeserializer()); return module; }
SimpleModule module = new SimpleModule(); module.addDeserializer( CoinMarketCapQuote.class, new CoinMarketCapQuote.CoinMarketCapQuoteDeserializer()); mapper.registerModule(module); Iterator<Map.Entry<String, JsonNode>> it = node.get("quotes").fields(); while (it.hasNext()) {
public static void configure(ObjectMapperModule mapper) { SimpleModule module = new SimpleModule(); module.addSerializer(org.joda.time.DateTimeZone.class, new DateTimeZoneSerializer()); module.addDeserializer(org.joda.time.DateTimeZone.class, new DateTimeZoneDeserializer()); mapper.registerModule(module); }
public EurekaJacksonCodec(String versionDeltaKey, String appsHashCodeKey) { this.versionDeltaKey = versionDeltaKey; this.appHashCodeKey = appsHashCodeKey; this.mapper = new ObjectMapper(); this.mapper.setSerializationInclusion(Include.NON_NULL); SimpleModule module = new SimpleModule("eureka1.x", VERSION); module.addSerializer(DataCenterInfo.class, new DataCenterInfoSerializer()); module.addSerializer(InstanceInfo.class, new InstanceInfoSerializer()); module.addSerializer(Application.class, new ApplicationSerializer()); module.addSerializer(Applications.class, new ApplicationsSerializer(this.versionDeltaKey, this.appHashCodeKey)); module.addDeserializer(LeaseInfo.class, new LeaseInfoDeserializer()); module.addDeserializer(InstanceInfo.class, new InstanceInfoDeserializer(this.mapper)); module.addDeserializer(Application.class, new ApplicationDeserializer(this.mapper)); module.addDeserializer(Applications.class, new ApplicationsDeserializer(this.mapper, this.versionDeltaKey, this.appHashCodeKey)); this.mapper.registerModule(module); Map<Class<?>, Supplier<ObjectReader>> readers = new HashMap<>(); readers.put(InstanceInfo.class, ()->mapper.reader().forType(InstanceInfo.class).withRootName("instance")); readers.put(Application.class, ()->mapper.reader().forType(Application.class).withRootName("application")); readers.put(Applications.class, ()->mapper.reader().forType(Applications.class).withRootName("applications")); this.objectReaderByClass = readers; Map<Class<?>, ObjectWriter> writers = new HashMap<>(); writers.put(InstanceInfo.class, mapper.writer().forType(InstanceInfo.class).withRootName("instance")); writers.put(Application.class, mapper.writer().forType(Application.class).withRootName("application")); writers.put(Applications.class, mapper.writer().forType(Applications.class).withRootName("applications")); this.objectWriterByClass = writers; }