List of usage examples for com.fasterxml.jackson.databind.module SimpleModule SimpleModule
public SimpleModule()
From source file:nl.ortecfinance.opal.jacksonweb.SimulationResponseTest.java
@Test public void testJsonIgnore() throws IOException { SimulationResponse resp = new SimulationResponse(); resp.setCapitalGoalProbabilities(Arrays.asList(new Double(10), null, new Double(33))); StringWriter sr = new StringWriter(); ObjectMapper om = new ObjectMapper(); SimpleModule module = new SimpleModule(); // module.addSerializer(List<Double[]>.class, new ListOfDoubleArraySerializer()); module.addSerializer(Double[].class, new MyDoubleArraySerializer()); om.registerModule(module);//from w ww. j av a2s . c o m om.setSerializationInclusion(JsonInclude.Include.NON_NULL); om.setSerializationInclusion(JsonInclude.Include.NON_EMPTY); om.writeValue(sr, resp); System.out.println("SimulationResponse=" + sr); }
From source file:com.strategicgains.hyperexpress.serialization.siren.jackson.SirenResourceSerializerTest.java
@BeforeClass public static void setUpBeforeClass() throws Exception { SimpleModule module = new SimpleModule(); module.addSerializer(SirenResource.class, new SirenResourceSerializer()); mapper.registerModule(module);// w w w . j av a 2 s .co m mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS) .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) .setSerializationInclusion(JsonInclude.Include.NON_NULL) .setVisibility(PropertyAccessor.FIELD, Visibility.ANY) .setVisibility(PropertyAccessor.GETTER, Visibility.NONE) .setVisibility(PropertyAccessor.SETTER, Visibility.NONE) .setVisibility(PropertyAccessor.IS_GETTER, Visibility.NONE) .setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ")); }
From source file:com.spotify.ffwd.filter.FilterDeserializerTest.java
@Before public void setup() { final SimpleModule m = new SimpleModule(); final Map<String, FilterDeserializer.PartialDeserializer> filters = new HashMap<>(); filters.put("and", new AndFilter.Deserializer()); filters.put("or", new OrFilter.Deserializer()); filters.put("key", new MatchKey.Deserializer()); filters.put("not", new NotFilter.Deserializer()); m.addDeserializer(Filter.class, new FilterDeserializer(filters)); mapper = new ObjectMapper(); mapper.registerModule(m);//from w w w . j a va 2 s . co m }
From source file:ijfx.service.overlay.io.OverlaySaver.java
public void save(List<? extends Overlay> overlays, File file) throws IOException { ObjectMapper mapper = new ObjectMapper(); SimpleModule module = new SimpleModule(); module.addSerializer(Overlay.class, new OverlaySerializer()); mapper.registerModule(module);/*from w ww . j a v a2 s . c om*/ mapper.writeValue(file, overlays); }
From source file:com.siemens.sw360.portal.common.ThriftJsonSerializer.java
public ThriftJsonSerializer() { // Create a module with the proper serializer for Thrift classes SimpleModule module = new SimpleModule(); module.addSerializer(TBase.class, new TBaseSerializer()); // Create the object mapper and register the module mapper = new ObjectMapper(); mapper.registerModule(module);/*from ww w . j a va 2 s . c o m*/ }
From source file:es.logongas.iothome.agent.http.Http.java
public Http() { this.objectMapper = new ObjectMapper(); objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); objectMapper.configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, true); SimpleModule module = new SimpleModule(); module.addSerializer(java.util.Date.class, new DateSerializer()); objectMapper.registerModule(module); }
From source file:no.ssb.jsonstat.v2.CollectionTest.java
@BeforeMethod public void setUp() throws Exception { // TODO mapper.registerModule(new SimpleModule()); }
From source file:ijfx.service.overlay.io.OverlayLoader.java
public List<Overlay> load(File f) throws IOException { ObjectMapper mapper = new ObjectMapper(); SimpleModule module = new SimpleModule(); module.addDeserializer(Overlay.class, new OverlayDeserializer(context)); mapper.registerModule(module);// ww w. ja v a 2 s. c o m try { return mapper.readValue(f, mapper.getTypeFactory().constructCollectionType(List.class, Overlay.class)); } catch (Exception e) { e.printStackTrace(); return new ArrayList<>(); } }
From source file:com.arpnetworking.test.junitbenchmarks.GCShapshotSerializerTest.java
@Test public void testSerialization() { final SimpleModule module = new SimpleModule(); module.addSerializer(GCSnapshot.class, new GCSnapshotSerializer()); final ObjectMapper mapper = ObjectMapperFactory.createInstance(); mapper.registerModule(module);/*w w w. jav a2s.c o m*/ final GCSnapshot testSnapshot = DataCreator.createGCSnapshot(); final JsonNode jsonNode = mapper.valueToTree(testSnapshot); Assert.assertTrue(jsonNode.isObject()); Assert.assertThat(jsonNode.get("accumulatedInvocations").asLong(), Matchers.greaterThanOrEqualTo(0L)); Assert.assertThat(jsonNode.get("accumulatedTime").asLong(), Matchers.greaterThanOrEqualTo(0L)); }