public class YamlParserUtils extends Object
Constructor and Description |
---|
YamlParserUtils() |
Modifier and Type | Method and Description |
---|---|
static List<String> |
convertAndDumpYamlFromFlatMap(Map<String,Object> flattenMap)
Converts a flat map into a nested map structure and outputs the result as a list of
YAML-formatted strings.
|
static <T> T |
convertToObject(String value,
Class<T> type) |
static Map<String,Object> |
loadYamlFile(File file)
Loads the contents of the given YAML file into a map.
|
static String |
toYAMLString(Object value)
Converts the given value to a string representation in the YAML syntax.
|
@Nonnull public static Map<String,Object> loadYamlFile(File file) throws Exception
file
- the YAML file to load.FileNotFoundException
- if the YAML file is not found.org.snakeyaml.engine.v2.exceptions.YamlEngineException
- if the file cannot be parsed.IOException
- if an I/O error occurs while reading from the file stream.Exception
public static String toYAMLString(Object value)
The resulting YAML string may have line breaks at the end of each line. This method removes the line break at the end of the string if it exists.
Note: This method may perform escaping on certain characters in the value to ensure proper YAML syntax.
value
- The value to be converted.public static List<String> convertAndDumpYamlFromFlatMap(Map<String,Object> flattenMap)
flattenMap
- A map containing flattened keys (e.g., "parent.child.key") associated with
their values.Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.