Search code examples
javasnakeyaml

Generate YAML file from string with SnakeYaml


Is it possible to parse with snakeyaml the following content (String)

environments.dev.url:http://dev.examle.com

environments.dev.name:Developer Setup

environments.prod.url:http://another.example.com

environments.prod.name:My Cool All

and obtain a YAML file

environments:
dev:
    url: http://dev.example.com
    name: Developer Setup
prod:
    url: http://another.example.com
    name: My Cool App

Solution

  • SnakeYaml does not provide in built functionality to parse/convert a given .properties file into .yaml file.

    You can try some third party libraries to convert your properties file into yaml file.

    properties-to-yaml

    props2yaml