private ObjectMapper createJsonMapper() { ObjectMapper mapper = new ObjectMapper(); SimpleModule module = new SimpleModule("LlamaModule", new Version(1, 0, 0, null)); module.addSerializer(new UUIDSerializer()); module.addSerializer(new ClientInfoImplSerializer()); module.addSerializer(new PlacedReservationSerializer()); module.addSerializer(new PlacedResourceSerializer()); mapper.registerModule(module); mapper.configure(SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS, false); return mapper; }
public JacksonJsonMapper(Class<T> type) { this.type = type; objectMapper = new ObjectMapper(); SimpleModule module = new SimpleModule("Atlassian Diagnostics Built-in", new Version(1, 0, 0, null)); // register a deserializer for ThreadDump to unmarshal it as a SimpleThreadDump module.addDeserializer(ThreadDump.class, new JsonDeserializer<ThreadDump>() { @Override public ThreadDump deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { return jp.readValueAs(SimpleThreadDump.class); } }); objectMapper.registerModule(module); }
/** * Adds in any custom modules desired for this project's {@link ObjectMapper}. */ private static void configureObjectMapper() { SimpleModule module = new SimpleModule("${groupId}:${artifactId}:${version}", new Version(1, 9, 2, "")); module.setMixInAnnotation(ValidationExampleChild.class, ValidationExampleChildMixIn.class); LOGGER.debug("Configured Jackson of Class/MixIn combination: ValidationExampleChild=ValidationExampleChildMixIn"); module.setMixInAnnotation(ValidationExample.class, ValidationExampleMixIn.class); LOGGER.debug("Configured Jackson of Class/MixIn combination: ValidationExample=ValidationExampleMixIn"); module.setMixInAnnotation(ValidationReferencedObject.class, ValidationReferencedObjectMixIn.class); LOGGER.debug("Configured Jackson of Class/MixIn combination: ValidationReferencedObject=ValidationReferencedObjectMixIn"); module.setMixInAnnotation(ValidationReferenceExample.class, ValidationReferenceExampleMixIn.class); LOGGER.debug("Configured Jackson of Class/MixIn combination: ValidationReferenceExample=ValidationReferenceExampleMixIn"); module.setMixInAnnotation(SimpleDomain.class, SimpleDomainMixIn.class); LOGGER.debug("Configured Jackson of Class/MixIn combination: SimpleDomain=SimpleDomainMixIn"); module.addAbstractTypeMapping(Messages.class, DefaultMessages.class); LOGGER.debug("Configured Jackson of Interface/Concrete class mapping: Messages->DefaultMessages"); module.setMixInAnnotation(Messages.class, MessagesMixIn.class); LOGGER.debug("Configured Jackson of Class/MixIn combination: Messages=MessagesMixIn"); module.setMixInAnnotation(InjectableMessages.class, InjectableMessagesMixIn.class); LOGGER.debug("Configured Jackson of Class/MixIn combination: InjectableMessages=InjectableMessagesMixIn"); module.addSerializer(Message.class, new MessageSerializer(ObjectMapperManager.class)); LOGGER.debug("Configured Jackson custom serializer: Message->MessageSerializer"); module.addDeserializer(Message.class, new MessageDeserializer()); LOGGER.debug("Configured Jackson custom deserializer: Message->MessageDeserializer"); objectMapper.registerModule(module); }
SimpleModule module = new SimpleModule("SamzaModule", new Version(1, 0, 0, "")); module.addSerializer(Partition.class, new PartitionSerializer()); module.addSerializer(SystemStreamPartition.class, new SystemStreamPartitionSerializer()); module.addKeySerializer(SystemStreamPartition.class, new SystemStreamPartitionKeySerializer()); module.addSerializer(TaskName.class, new TaskNameSerializer()); module.addSerializer(TaskMode.class, new TaskModeSerializer()); module.addDeserializer(Partition.class, new PartitionDeserializer()); module.addDeserializer(SystemStreamPartition.class, new SystemStreamPartitionDeserializer()); module.addKeyDeserializer(SystemStreamPartition.class, new SystemStreamPartitionKeyDeserializer()); module.addDeserializer(Config.class, new ConfigDeserializer()); module.addDeserializer(TaskMode.class, new TaskModeDeserializer()); mapper.getDeserializationConfig().addMixInAnnotations(JobModel.class, JsonJobModelMixIn.class); module.addDeserializer(ContainerModel.class, new JsonDeserializer<ContainerModel>() { @Override public ContainerModel deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
public static Module build() { Version version = new Version(1, 0, 0, null); SimpleModule module = new SimpleModule("values", version); // Class<DecimalValue> klazDecimal = DecimalValue.class; module.addSerializer(new DecimalValueSer(klazDecimal)); module.addDeserializer(klazDecimal, new DecimalValueDes(klazDecimal)); // Class<PriceValue> klazPrice = PriceValue.class; module.addSerializer(new PriceValueSer(klazPrice)); module.addDeserializer(klazPrice, new PriceValueDes(klazPrice)); // Class<SizeValue> klazSize = SizeValue.class; module.addSerializer(new SizeValueSer(klazSize)); module.addDeserializer(klazSize, new SizeValueDes(klazSize)); // Class<TextValue> klazText = TextValue.class; module.addSerializer(new TextValueSer(klazText)); module.addDeserializer(klazText, new TextValueDes(klazText)); // Class<TimeValue> klazTime = TimeValue.class; module.addSerializer(new TimeValueSer(klazTime)); module.addDeserializer(klazTime, new TimeValueDes(klazTime)); // return module; }
public <T> void addSerializer(JsonSerializer<T> serializer) { module.addSerializer(serializer); }
/** * creates a new SimpleModule for holding the serializers * @return SimpleModule */ private static SimpleModule createhRavenModule() { return new SimpleModule("hRavenModule", new Version(0, 4, 0, null)); }
ColorCommand.class); SimpleModule module = new SimpleModule("insight-json", new Version(1, 7, 2, "insight")); module.addAbstractTypeMapping(TraceInterface.class, Trace.class); module.addDeserializer(Serializable.class, new JsonCustomSerializableDeserializer()); module.addDeserializer(Frame.class, new JsonCustomFrameDeserializer()); module.addDeserializer(Operation.class, new JsonOperationDeserializer()); module.addDeserializer(FrameId.class, new JsonFrameIdDeserializer()); module.addDeserializer(TraceId.class, new JsonTraceIdDeserializer()); module.addDeserializer(ResourceKey.class, new JsonResourceKeyDeserializer()); module.addDeserializer(SparseHistogram.class, new JsonSparseHistogramDeserializer()); module.addDeserializer(HistogramDefinition.class, new JsonHistogramDefinitionDeserializer()); module.addDeserializer(ApplicationName.class, new JsonApplicationNameDeserializer());
public static Module getModule() { SimpleModule module = new STJSSimpleModule("MyModule", new Version(1, 0, 0, null)); module.addSerializer(new JSArraySerializer()); module.addSerializer(new JSMapSerializer()); module.addSerializer(new JSDateSerializer()); module.addDeserializer(Date.class, new JSDateDeserializer()); return module; }
public <T> void addSimpleModule(SimpleModule module, Class<T> type, JsonDeserializer<T> deSer) { module.addDeserializer(type, deSer); }
SimpleModule module = new SimpleModule("SamzaModule", new Version(1, 0, 0, "")); module.addSerializer(Partition.class, new PartitionSerializer()); module.addSerializer(SystemStreamPartition.class, new SystemStreamPartitionSerializer()); module.addKeySerializer(SystemStreamPartition.class, new SystemStreamPartitionKeySerializer()); module.addSerializer(TaskName.class, new TaskNameSerializer()); module.addDeserializer(Partition.class, new PartitionDeserializer()); module.addDeserializer(SystemStreamPartition.class, new SystemStreamPartitionDeserializer()); module.addKeyDeserializer(SystemStreamPartition.class, new SystemStreamPartitionKeyDeserializer()); module.addDeserializer(Config.class, new ConfigDeserializer()); mapper.getDeserializationConfig().addMixInAnnotations(JobModel.class, JsonJobModelMixIn.class); module.addDeserializer(ContainerModel.class, new JsonDeserializer<ContainerModel>() { @Override public ContainerModel deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
public static final ObjectMapper getObjectMapper() { final ObjectMapper mapper = new ObjectMapper(); final SimpleModule gnipActivityModule = new SimpleModule("gnip.activity", new Version(1, 0, 0, null)); gnipActivityModule.addDeserializer(Geo.class, new GeoDeserializer(Geo.class)); gnipActivityModule.addSerializer(Geo.class, new GeoSerializer()); mapper.registerModule(gnipActivityModule); mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.configure(SerializationConfig.Feature.WRITE_NULL_PROPERTIES, false); return mapper; }
public <T> void addSerializer(Class<T> clazz, JsonSerializer<T> serializer) { module.addSerializer(clazz, serializer); }
/** * creates a new SimpleModule for holding the serializers * @return SimpleModule */ private static SimpleModule createhRavenModule() { return new SimpleModule("hRavenModule", new Version(0, 4, 0, null)); }
private void formatProcessingStatusAsJson(ProcessingStatusType pst) throws JsonGenerationException, JsonMappingException, IOException { // serialize to JSON using Jackson (part of Mule ESB dependencies, Mule // 3.3 bundles Jackson 1.8) ObjectMapper om = new ObjectMapper(); SimpleModule customSerializerMod = new SimpleModule( "CustomSerializerModule", new Version(1, 0, 0, null)); customSerializerMod.addSerializer(new JsonCustomSerializer()); om.registerModule(customSerializerMod); procStatus = om.writeValueAsString(pst.getProcessingStatusList()); }
SimpleModule module = new SimpleModule("SamzaModule", new Version(1, 0, 0, "")); module.addSerializer(Partition.class, new PartitionSerializer()); module.addSerializer(SystemStreamPartition.class, new SystemStreamPartitionSerializer()); module.addKeySerializer(SystemStreamPartition.class, new SystemStreamPartitionKeySerializer()); module.addSerializer(TaskName.class, new TaskNameSerializer()); module.addDeserializer(Partition.class, new PartitionDeserializer()); module.addDeserializer(SystemStreamPartition.class, new SystemStreamPartitionDeserializer()); module.addKeyDeserializer(SystemStreamPartition.class, new SystemStreamPartitionKeyDeserializer()); module.addDeserializer(Config.class, new ConfigDeserializer()); mapper.getDeserializationConfig().addMixInAnnotations(JobModel.class, JsonJobModelMixIn.class); module.addDeserializer(ContainerModel.class, new JsonDeserializer<ContainerModel>() { @Override public ContainerModel deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
public static SimpleModule getCustomSimpleModuleWithXSS() { //Define a SimpleModule to control Serialization mechanism. SimpleModule module = new SimpleModule("HTML XSS Serializer", new Version(1, 0, 0, "FINAL")); //module.addSerializer(String.class, new JSONHtmlXssSerializer()); module.addDeserializer(String.class, new JSONStringXSSDeserializer()); return module; } }
public <T> void addSimpleModule(SimpleModule module, Class<T> type, JsonSerializer<T> ser) { module.addSerializer(type, ser); }
public DefaultMasterNodeInfoMapper(JsonFactory factory) { super(factory); SimpleModule serializerModule = new SimpleModule("default serializers", new Version(1, 0, 0, null)); registerModule(serializerModule); configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); configure(SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS, false); } }
/** * @return a new {@link ObjectMapper} instance which allows single * quotes and unquoted keys by default */ private static ObjectMapper createObjectMapper() { ObjectMapper mapper = new ObjectMapper(); mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true); mapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true); SimpleModule wbModule = new SimpleModule("wicket-bootstrap", new Version(1, 0, 0, null)); wbModule.addSerializer(ConfigModel.class, new JsonSerializer<ConfigModel>() { @Override public void serialize(ConfigModel value, JsonGenerator jsonGenerator, SerializerProvider provider) throws IOException { jsonGenerator.writeString(value.getObject()); } }); wbModule.addSerializer(IDataSource.class, new JsonSerializer<IDataSource>() { @Override public void serialize(IDataSource value, JsonGenerator jsonGenerator, SerializerProvider provider) throws IOException { jsonGenerator.writeObject(stringify(value.load())); } }); mapper.registerModule(wbModule); return mapper; }