public static PluginDescriptor readValue(String content) throws IOException { SimpleModule module = new SimpleModule(); module.addAbstractTypeMapping(InstrumentationConfig.class, ImmutableInstrumentationConfig.class); module.addAbstractTypeMapping(PropertyDescriptor.class, ImmutablePropertyDescriptor.class); ObjectMapper mapper = ObjectMappers.create(module); return mapper.readValue(content, ImmutablePluginDescriptor.class); }
public static void configureStockJoltObjectMapper( ObjectMapper objectMapper ) { // All Json maps should be deserialized into LinkedHashMaps. SimpleModule stockModule = new SimpleModule("stockJoltMapping", new Version(1, 0, 0, null, null, null)) .addAbstractTypeMapping( Map.class, LinkedHashMap.class ); objectMapper.registerModule(stockModule); // allow the mapper to parse JSON with comments in it objectMapper.configure( JsonParser.Feature.ALLOW_COMMENTS, true); }
@Override public void customizeModule(final SimpleModule module) { module.addAbstractTypeMapping(Player.class, MongoPlayer.class); }
SimpleModule m = new SimpleModule(...); m.addAbstractTypeMapping(ISemaphore.class, SemaphoreImpl.class); mapper.registerModule(m);
public static ObjectMapper jsonMapper() { final ObjectMapper mapper = new ObjectMapper().registerModule(new SimpleModule() .addAbstractTypeMapping(DistributionSnapshot.class, RuntimeSnapshot.class) .addAbstractTypeMapping(BundleInfo.class, BundleInfoImpl.class) .addAbstractTypeMapping(BundleGroup.class, BundleGroupImpl.class) .addAbstractTypeMapping(ComponentInfo.class, ComponentInfoImpl.class) .addAbstractTypeMapping(ExtensionInfo.class, ExtensionInfoImpl.class) .addAbstractTypeMapping(OperationInfo.class, OperationInfoImpl.class) .addAbstractTypeMapping(SeamComponentInfo.class, SeamComponentInfoImpl.class) .addAbstractTypeMapping(ServiceInfo.class, ServiceInfoImpl.class) .addAbstractTypeMapping(DocumentationItem.class, ResourceDocumentationItem.class)); mapper.addMixIn(OperationDocumentation.Param.class, OperationDocParamMixin.class); return mapper; }
private void registerAbstractTypeMappings(SimpleModule module) { module.addAbstractTypeMapping(XMLGregorianCalendar.class, XMLValues.xmlGregorianCalendarType()); module.addAbstractTypeMapping(Calendar.class, GregorianCalendar.class); }
protected static void initialize() { objectMapper = new ObjectMapper(); SimpleModule module = new SimpleModule(); module.addAbstractTypeMapping(Page.class, PageResponse.class); objectMapper.registerModule(module); AnnotationIntrospector introspector = new JacksonAnnotationIntrospector(); objectMapper.setAnnotationIntrospector(introspector); objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); objectMapper.configure(SerializationFeature.INDENT_OUTPUT, true); objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); objectMapper.configure(MapperFeature.DEFAULT_VIEW_INCLUSION, false); }
public static void configureStockJoltObjectMapper( ObjectMapper objectMapper ) { // All Json maps should be deserialized into LinkedHashMaps. SimpleModule stockModule = new SimpleModule("stockJoltMapping", new Version(1, 0, 0, null, null, null)) .addAbstractTypeMapping( Map.class, LinkedHashMap.class ); objectMapper.registerModule(stockModule); // allow the mapper to parse JSON with comments in it objectMapper.configure( JsonParser.Feature.ALLOW_COMMENTS, true); }
protected static void initialize() { JacksonXmlModule xmlModule = new JacksonXmlModule(); xmlModule.setDefaultUseWrapper(false); objectMapper = new XmlMapper(xmlModule); SimpleModule module = new SimpleModule(); module.addAbstractTypeMapping(Page.class, PageResponse.class); objectMapper.registerModule(module); AnnotationIntrospector introspector = new JacksonAnnotationIntrospector(); objectMapper.setAnnotationIntrospector(introspector); objectMapper.configure(MapperFeature.DEFAULT_VIEW_INCLUSION, false); }
private List<XpmRegion> loadXpmRegions(Localization localization) { final StaticContentItem item; try { item = contentProvider.getStaticContent(REGIONS_PATH, localization.getId(), localization.getPath()); } catch (ContentProviderException e) { LOG.error("Exception while reading XPM regions configuration", e); return null; } try (final InputStream in = item.getContent()) { SimpleModule module = new SimpleModule("ComponentTypeMapper", Version.unknownVersion()); module.addAbstractTypeMapping(ComponentType.class, ComponentTypeImpl.class); objectMapper.registerModule(module); // important, otherwise won't have any effect on mapper's configuration return objectMapper.readValue(in, new TypeReference<List<XpmRegionImpl>>() { }); } catch (IOException e) { LOG.error("Exception while reading XPM regions configuration", e); return null; } } }
/** * Setup serialization and deserialization for Jackson-annotated {@link Command} subclasses. * All Jackson-annotated {@code Command} subclasses <strong>must</strong> derive from a single base class. * <p/> * The following <strong>is</strong> supported: * <pre> * Object * +-- CMD_BASE * +-- CMD_0 * +-- CMD_1 * </pre> * And the following is <strong>not</strong> supported: * <pre> * Object * +-- CMD_0 * +-- CMD_1 * </pre> * See {@code RaftAgent} for more on which {@code Command} types are supported. * * @param mapper instance of {@code ObjectMapper} with which the serialization/deserialization mapping is registered * @param commandSubclassKlass the base class of all the Jackson-annotated {@code Command} classes * * @see io.libraft.agent.RaftAgent */ public static <T extends Command> void setupJacksonAnnotatedCommandSerializationAndDeserialization(ObjectMapper mapper, Class<T> commandSubclassKlass) { SimpleModule module = new SimpleModule("raftrpc-jackson-command-module", new Version(0, 0, 0, "inline", "io.libraft", "raftrpc-jackson-command-module")); module.addAbstractTypeMapping(Command.class, commandSubclassKlass); module.addDeserializer(commandSubclassKlass, new RaftRPCCommand.PassThroughDeserializer<T>(commandSubclassKlass)); mapper.registerModule(module); }
.registerModule(new JavaMoneyModule()) .registerModule(new SphereEnumModule()) .registerModule(new SimpleModule().addAbstractTypeMapping(Set.class, LinkedHashSet.class)) .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) .configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false)