Reputation: 63
I wanted to read and write some content from yaml
file in Spring Boot
application. Which parser I have to use and How? If someone knows any idea, then please elaborate with an example.
thank you.
Upvotes: 0
Views: 5718
Reputation: 190
You can use SnakeYaml
Add dep e.g snakeyaml
The Yaml class is the entry point for the API:
Yaml yaml = new Yaml();
Now we’ll parse a YAML document with the Yaml class:
Yaml yaml = new Yaml();
InputStream inputStream = this.getClass()
.getClassLoader()
.getResourceAsStream("customer.yaml");
Map<String, Object> obj = yaml.load(inputStream);
System.out.println(obj);
Upvotes: 1