List of usage examples for com.fasterxml.jackson.databind ObjectMapper registerModule
public ObjectMapper registerModule(Module module)
From source file:je.backit.rest.JacksonContextResolver.java
private static ObjectMapper init() { ObjectMapper om = new ObjectMapper(); om.registerModule(new JSR310Module()); om.registerModule(new JooqModule()); om.setSerializationInclusion(JsonInclude.Include.NON_NULL); om.getFactory().configure(JsonGenerator.Feature.AUTO_CLOSE_TARGET, false) .configure(JsonGenerator.Feature.FLUSH_PASSED_TO_STREAM, false); om.configure(WRITE_DATES_AS_TIMESTAMPS, false); om.setVisibilityChecker(om.getSerializationConfig().getDefaultVisibilityChecker() .withIsGetterVisibility(NONE).withGetterVisibility(NONE).withFieldVisibility(ANY)); return om;//from w w w. jav a 2s.c om }
From source file:org.mythtv.services.api.JacksonUtils.java
public static ObjectMapper initObjectMapper() { StdDelegatingDeserializer<ArrayOfString> delegatingDeserializer = new StdDelegatingDeserializer<ArrayOfString>( new ArrayOfStringConverter()); SimpleModule customModule = new SimpleModule("org.mythtv.services.api.module", new Version(1, 0, 0, null, null, null)).addDeserializer(ArrayOfString.class, delegatingDeserializer); ObjectMapper objectMapper = new ObjectMapper(); objectMapper.registerModule(new JodaModule()); objectMapper.registerModule(customModule); objectMapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true); return objectMapper; }
From source file:br.com.catbag.gifreduxsample.models.AppState.java
public static AppState fromJson(String json) throws IOException { ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new GuavaModule()); return mapper.readValue(json, AppState.class); }
From source file:DataLoader.java
private static String toJSON(Object entity) { String json = null;//from w w w .ja v a2s . c o m ObjectifyJacksonModule ojm = new ObjectifyJacksonModule(); ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(ojm); try { json = mapper.writeValueAsString(entity); } catch (JsonProcessingException jpe) { jpe.printStackTrace(); } return json; }
From source file:de.cinovo.cloudconductor.api.lib.helper.MapperFactory.java
/** * @return the object mapper//from w w w . ja v a 2 s.c om */ public static ObjectMapper createDefault() { ObjectMapper m = new ObjectMapper(); m.registerModule(new JodaModule()); m.registerModule(new GuavaModule()); m.setSerializationInclusion(Include.NON_NULL); m.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS); m.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); m.enable(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS); m.enable(MapperFeature.AUTO_DETECT_GETTERS); return m; }
From source file:com.chiralBehaviors.autoconfigure.configuration.YamlHelper.java
public static Configuration fromYaml(InputStream yaml) throws JsonParseException, JsonMappingException, IOException { ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); mapper.registerModule(new GossipScopeModule()); return mapper.readValue(yaml, Configuration.class); }
From source file:com.spectralogic.ds3autogen.Ds3NameMapperParserImpl.java
private static ObjectMapper initDs3NameMapper() { final ObjectMapper objectMapper = new ObjectMapper(); objectMapper.registerModule(new GuavaModule()); return objectMapper; }
From source file:org.mongojack.internal.MongoJackModule.java
/** * Configure the given object mapper to be used with MongoJack. Please call * this method rather than calling//from w w w.j a v a2 s .com * objectMapper.with(MongoJacksonMapperModule.INSTANCE), because Jacksons * module system doesn't allow MongoJack to do all the configuration it * needs to do. This method will do that configuration though. * * @param objectMapper * The object mapper to configure * @return This object mapper (for chaining) */ public static ObjectMapper configure(ObjectMapper objectMapper) { objectMapper.registerModule(INSTANCE); objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); return objectMapper; }
From source file:com.chiralBehaviors.slp.hive.configuration.YamlHelper.java
public static EngineConfiguration fromYaml(InputStream yaml) throws JsonParseException, JsonMappingException, IOException { ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); mapper.registerModule(new EngineModule()); return mapper.readValue(yaml, EngineConfiguration.class); }
From source file:com.hellblazer.gossip.configuration.YamlHelper.java
public static GossipConfiguration fromYaml(InputStream yaml) throws JsonParseException, JsonMappingException, IOException { ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); mapper.registerModule(new GossipModule()); return mapper.readValue(yaml, GossipConfiguration.class); }