Search code examples
javasnakeyaml

How to parse YAML with SnakeYaml low-level API like getAsInt?


The SnakeYaml docs provide examples how to de-serialize YAML into Java Class.

I'm looking for simple low-level API that's similar to GSON getAsInt, does SnakeYaml support that?


Solution

  • If you use SnakeYaml's load method on a Yaml object created without specifying a representation type, you will get a data structure composed of List and Map collections, with the "values" represented as instances of String, Integer and so on.

    It sounds like that is close to what you are looking for.