List of usage examples for com.fasterxml.jackson.databind ObjectMapper disable
public ObjectMapper disable(SerializationFeature f)
From source file:com.metamx.datatypes.ExampleWriteNewLineJson.java
public static void main(String[] args) throws Exception { final MmxAuctionSummary sampleAuction1 = MmxAuctionSummary.builder() .timestamp(new DateTime("2014-01-01T00:00:00.000Z")).auctionType(2).build(); final MmxAuctionSummary sampleAuction2 = MmxAuctionSummary.builder() .timestamp(new DateTime("2014-01-01T01:00:00.000Z")).auctionType(1).build(); List<MmxAuctionSummary> auctionList = Arrays.asList(sampleAuction1, sampleAuction2); final String separator = "\n"; final ObjectMapper objectMapper = new ObjectMapper(); objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); final OutputStream outStream = new ByteArrayOutputStream(); for (MmxAuctionSummary auction : auctionList) { outStream.write(objectMapper.writeValueAsBytes(auction)); outStream.write(separator.getBytes()); }/*w w w. j a v a 2s.co m*/ System.out.println(outStream.toString()); }
From source file:org.apache.ode.jacob.examples.helloworld.HelloWorld.java
@SuppressWarnings("unchecked") public static void main(String args[]) throws Exception { // enable logging // BasicConfigurator.configure(); List<Logger> loggers = Collections.<Logger>list(LogManager.getCurrentLoggers()); loggers.add(LogManager.getRootLogger()); for (Logger logger : loggers) { logger.setLevel(Level.OFF); }//from w w w. j a v a 2s.com SmileFactory sf = null; // // enable smile: // sf = new SmileFactory(); // sf.enable(SmileGenerator.Feature.CHECK_SHARED_STRING_VALUES); // sf.enable(SmileGenerator.Feature.ENCODE_BINARY_AS_7BIT); ObjectMapper mapper = new ObjectMapper(sf); mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS); mapper.registerModule(new JacobModule()); JacobVPU vpu = new JacobVPU(); JacksonExecutionQueueImpl queue = new JacksonExecutionQueueImpl(); vpu.setContext(queue); long start = System.currentTimeMillis(); vpu.inject(new HelloWorld()); while (vpu.execute()) { queue = loadAndRestoreQueue(mapper, (JacksonExecutionQueueImpl) vpu.getContext()); vpu.setContext(queue); System.out.println(vpu.isComplete() ? "<0>" : "."); //vpu.dumpState(); } System.out.println("Runtime in ms: " + (System.currentTimeMillis() - start)); vpu.dumpState(); }
From source file:io.fabric8.kubernetes.pipeline.devops.elasticsearch.JsonUtils.java
public static ObjectMapper createObjectMapper() { ObjectMapper mapper = new ObjectMapper(); mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); return mapper; }
From source file:org.novamedia.novamail.jobserver.rest.ObjectMapperProvider.java
private static ObjectMapper createDefaultMapper() { final ObjectMapper mapper = new ObjectMapper(); mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); mapper.enable(SerializationFeature.INDENT_OUTPUT); return mapper; }
From source file:uk.co.flax.biosolr.ontology.core.ols.ObjectMapperResolver.java
private static ObjectMapper createDefaultMapper() { ObjectMapper defaultMapper = new ObjectMapper(); defaultMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); defaultMapper.disable(MapperFeature.CAN_OVERRIDE_ACCESS_MODIFIERS); return defaultMapper; }
From source file:nl.salp.warcraft4j.battlenet.api.JacksonJsonApiResultParser.java
/** * Create the mapper to use./* ww w .java2s.co m*/ * <p/> * TODO Move to a different Guice managed class for easy switching of implementations/testing. * * @return The mapper. */ private static ObjectMapper createMapper() { ObjectMapper mapper = new ObjectMapper(); mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); // TODO Add any needed mapping logic return mapper; }
From source file:org.bigloupe.web.monitor.util.JSONUtil.java
public static Object readJson(String json, TypeReference type) throws IOException { ObjectMapper om = new ObjectMapper(); om.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); // not currently setting successors, only successorNames return om.readValue(json, type); }
From source file:org.hawkular.datamining.rest.json.JacksonConfig.java
public static void initializeObjectMapper(ObjectMapper mapper) { mapper.enable(SerializationFeature.INDENT_OUTPUT); mapper.disable(SerializationFeature.WRITE_NULL_MAP_VALUES); mapper.disable(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS); mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY); ObjectMapperConfig.config(mapper);// ww w . j av a2 s . co m }
From source file:jenkins.plugins.sonarparser.SonarReportParser.java
public static SonarReport parse(InputStream input) throws IOException { ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new JodaDateTimeModule()); mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); SonarReport report = mapper.readValue(input, SonarReport.class); return report; }
From source file:dk.dma.navnet.client.AbstractClientConnectionTest.java
protected static String persist(Object o) { ObjectMapper om = new ObjectMapper(); om.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS); try {/*from w ww . ja va2 s . c o m*/ return om.writeValueAsString(o); } catch (JsonProcessingException e) { throw new IllegalArgumentException("Could not be persisted", e); } }