io.github.yamlpath.utils.SerializationUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of yaml-path Show documentation
Show all versions of yaml-path Show documentation
A Java DSL for reading YAML documents and replacing values
package io.github.yamlpath.utils;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator;
public final class SerializationUtils {
private static final String DOCUMENT_DELIMITER = "---";
private static final ObjectMapper YAML_MAPPER = createYamlMapper(
new YAMLGenerator.Feature[] { YAMLGenerator.Feature.MINIMIZE_QUOTES,
YAMLGenerator.Feature.ALWAYS_QUOTE_NUMBERS_AS_STRINGS,
YAMLGenerator.Feature.INDENT_ARRAYS_WITH_INDICATOR },
new SerializationFeature[] { SerializationFeature.INDENT_OUTPUT }, new SerializationFeature[] {
SerializationFeature.WRITE_NULL_MAP_VALUES, SerializationFeature.WRITE_EMPTY_JSON_ARRAYS });
private SerializationUtils() {
}
public static ObjectMapper yamlMapper() {
return YAML_MAPPER;
}
/**
* Unmarshals a file into a list of maps.
*
* @param inputStream
* The {@link InputStream}.
*
* @return
*/
public static List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy