List of usage examples for com.fasterxml.jackson.databind ObjectMapper canSerialize
public boolean canSerialize(Class<?> type)
From source file:com.feedzai.fos.api.ModelConfigTest.java
@Test public void testJacksonSerialization() throws IOException { CategoricalAttribute categorical = new CategoricalAttribute("categoric", Arrays.asList("abc", "def")); NumericAttribute numeric = new NumericAttribute("numeric"); List<Attribute> attributes = Arrays.<Attribute>asList(categorical, numeric); Map<String, String> properties = new HashMap<>(); properties.put("p1", "value1"); properties.put("p2", "value2"); ModelConfig config = new ModelConfig(attributes, properties); ObjectMapper mapper = new ObjectMapper(); Assert.assertTrue(mapper.canSerialize(config.getClass())); String json = mapper.writeValueAsString(config); System.out.println(json);//from w ww . j a v a 2s.c om System.out.println(config); ModelConfig deserialized = mapper.readValue(json, config.getClass()); assertEquals(config, deserialized); }
From source file:org.camunda.spin.impl.json.jackson.format.JacksonJsonDataFormatMapper.java
public boolean canMap(Object parameter) { ObjectMapper objectMapper = format.getObjectMapper(); if (parameter != null) { return objectMapper.canSerialize(parameter.getClass()); } else {/*from www . java 2 s. co m*/ return false; } }