File: YamlUtils.java

package info (click to toggle)
python-schema-salad 8.9.20251102115403-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,060 kB
  • sloc: python: 19,247; cpp: 2,631; cs: 1,869; java: 1,341; makefile: 187; xml: 184; sh: 103; javascript: 46
file content (31 lines) | stat: -rw-r--r-- 1,025 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package ${package}.utils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.regex.Pattern;

import org.snakeyaml.engine.v2.api.Load;
import org.snakeyaml.engine.v2.api.LoadSettings;
import org.snakeyaml.engine.v2.nodes.Tag;
import org.snakeyaml.engine.v2.resolver.ScalarResolver;
import org.snakeyaml.engine.v2.schema.CoreSchema;

public class YamlUtils {

	public static Map<String, Object> mapFromString(final String text) {
		LoadSettings settings = LoadSettings.builder().setSchema(new CoreSchema()).build();
		Load load = new Load(settings);
		final Map<String, Object> result = (Map<String, Object>) load.loadFromString(text);
		return result;
	}

	public static List<Object> listFromString(final String text) {
		LoadSettings settings = LoadSettings.builder().setSchema(new CoreSchema()).build();
		Load load = new Load(settings);
		final List<Object> result = (List<Object>) load.loadFromString(text);
		return result;
	}
}