List of usage examples for com.fasterxml.jackson.databind ObjectMapper enable
public ObjectMapper enable(SerializationFeature f)
From source file:nl.knaw.huygens.alexandria.concordion.JsonConfiguration.java
private static ObjectMapper createDefaultMapper() { final ObjectMapper mapper = new ObjectMapper(); Log.debug("Configuring Jackson ObjectMapper: [" + mapper + "]"); mapper.enable(SerializationFeature.INDENT_OUTPUT); mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); // mapper.disable(SerializationFeature.WRITE_DURATIONS_AS_TIMESTAMPS); mapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY); return mapper; }
From source file:com.googlecode.wickedcharts.highcharts.jackson.JsonRenderer.java
private static ObjectMapper createDefaultObjectMapper() { ObjectMapper mapper = new ObjectMapper(); mapper.enable(SerializationFeature.INDENT_OUTPUT); mapper.disable(SerializationFeature.WRITE_NULL_MAP_VALUES); mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS); mapper.setSerializationInclusion(Include.NON_NULL); return mapper; }
From source file:io.confluent.kafka.connect.source.Data.java
public static Map<String, String> settings(File targetDir) { SchemaConfig config = schemaConfig(); ObjectMapper objectMapper = new ObjectMapper(); objectMapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING); objectMapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING); Map<String, String> result = new LinkedHashMap<>(); try {/* w w w . j a v a 2s. com*/ String content = objectMapper.writeValueAsString(config); result.put(SpoolDirectoryConfig.CSV_SCHEMA_CONF, content); } catch (JsonProcessingException e) { throw new IllegalStateException(e); } File inputDirectory = new File(targetDir, "input"); inputDirectory.mkdirs(); result.put(SpoolDirectoryConfig.INPUT_PATH_CONFIG, inputDirectory.getAbsolutePath()); File finishDirectory = new File(targetDir, "finished"); result.put(SpoolDirectoryConfig.FINISHED_PATH_CONFIG, finishDirectory.getAbsolutePath()); finishDirectory.mkdirs(); File errorDirectory = new File(targetDir, "error"); result.put(SpoolDirectoryConfig.ERROR_PATH_CONFIG, errorDirectory.getAbsolutePath()); errorDirectory.mkdirs(); result.put(SpoolDirectoryConfig.TOPIC_CONF, TOPIC); // result.put(SpoolDirectoryConfig.KEY_FIELDS_CONF, "id"); result.put(SpoolDirectoryConfig.CSV_FIRST_ROW_AS_HEADER_CONF, "true"); result.put(SpoolDirectoryConfig.INPUT_FILE_PATTERN_CONF, "^.+\\.csv$"); result.put(SpoolDirectoryConfig.CSV_NULL_FIELD_INDICATOR_CONF, CSVReaderNullFieldIndicator.BOTH.name()); result.put(SpoolDirectoryConfig.CSV_PARSER_TIMESTAMP_DATE_FORMATS_CONF, "yyyy-MM-dd'T'HH:mm:ss'Z'"); result.put(SpoolDirectoryConfig.RECORD_PROCESSOR_CLASS_CONF, CSVRecordProcessor.class.getName()); result.put(SpoolDirectoryConfig.BATCH_SIZE_CONF, "100"); result.put(SpoolDirectoryConfig.CSV_SCHEMA_NAME_CONF, Data.class.getName() + "Schema"); return result; }
From source file:io.fabric8.maven.core.extenvvar.ExternalEnvVarHandler.java
/** * Creates a configured Jackson object mapper for parsing JSON *//*from www .j a v a 2 s. co m*/ private static ObjectMapper createObjectMapper() { ObjectMapper mapper = new ObjectMapper(); mapper.enable(SerializationFeature.INDENT_OUTPUT); return mapper; }
From source file:de.tudarmstadt.ukp.dkpro.argumentation.io.writer.json.JsonStreamDumpWriter.java
/** * TODO: Make this configurable via parameters passed to annotators of this class *//* w w w.ja va2 s . c om*/ private static ObjectMapper createObjectMapper() { final ObjectMapper result = new ObjectMapper(); result.enable(SerializationFeature.INDENT_OUTPUT); return result; }
From source file:io.vertx.stack.model.Stack.java
/** * Reads a stack descriptor./* ww w .j av a 2 s .co m*/ * * @param descriptor the descriptor, must be a valid YAML file. * @return the created stack */ public static Stack fromDescriptor(File descriptor) { ObjectMapper mapper = new ObjectMapper(); mapper = mapper.enable(JsonParser.Feature.ALLOW_COMMENTS) .enable(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES) .enable(JsonParser.Feature.ALLOW_SINGLE_QUOTES) .enable(JsonParser.Feature.STRICT_DUPLICATE_DETECTION); try { return mapper.readValue(descriptor, Stack.class); } catch (IOException e) { throw new IllegalArgumentException("Cannot load stack from " + descriptor.getAbsolutePath(), e); } }
From source file:org.brnvrn.Main.java
/** * Parse a HTML document, add tools to the list *///from ww w .j av a 2s. c o m private static ObjectMapper parseDocument(List<Tool> tools, Document doc, boolean obsolete) { // http://jsoup.org/apidocs/org/jsoup/select/Selector.html Elements category_div = doc.select("div.container div.row:has(table)"); // we loop over each category table System.out.println("Parsing " + (obsolete ? "obsolete" : "") + " doc. ###"); System.out.println(" Found " + category_div.size() + " categories."); for (Element tool_div : category_div) { String category = tool_div.select("strong").text(); parseCategory(tools, tool_div, category, obsolete); } System.out.println(" Got " + tools.size() + " tools."); ObjectMapper objectMapper = new ObjectMapper(); objectMapper.enable(SerializationFeature.INDENT_OUTPUT); return objectMapper; }
From source file:com.trusolve.ant.filters.SynapseAPISwaggerFilter.java
public static Reader readDocument(Reader in) throws JsonProcessingException, IOException { ObjectMapper jsonIn = new ObjectMapper(); JsonNode jn = jsonIn.readTree(in);// ww w .j a va 2s. c o m fixGetPaths(jn); jsonIn.enable(SerializationFeature.INDENT_OUTPUT); return new StringReader(jsonIn.writeValueAsString(jn)); }
From source file:de.javagl.jgltf.browser.MenuNodesCreator.java
/** * Write the given list of {@link MenuNode} objects as JSON to the * given output stream. The caller is responsible for closing the * given stream.//from www. ja v a2s.c o m * * @param menuNodes The menu nodes * @param outputStream The output stream * @throws IOException If an IO error occurs */ private static void write(List<? extends MenuNode> menuNodes, OutputStream outputStream) throws IOException { ObjectMapper objectMapper = new ObjectMapper(); objectMapper.setSerializationInclusion(Include.NON_NULL); objectMapper.enable(SerializationFeature.INDENT_OUTPUT); objectMapper.writeValue(outputStream, menuNodes); }
From source file:com.yahoo.gondola.container.Utils.java
public static ObjectMapper getObjectMapperInstance() { if (objectMapper == null) { ObjectMapper mapper = new ObjectMapper(); mapper.enable(SerializationFeature.WRITE_NULL_MAP_VALUES); mapper.setVisibility(PropertyAccessor.GETTER, JsonAutoDetect.Visibility.NONE); mapper.setVisibility(PropertyAccessor.IS_GETTER, JsonAutoDetect.Visibility.NONE); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS); objectMapper = mapper;//w ww .j a v a2 s .c o m } return objectMapper; }