6

I have a YAML file that I'm using as sort of a config file. It ooks like this,

tests:
    - category: some_category
      test:
          - name: hello
            key1: value1
            key2: value2

          - name: hithere
            key1: value1
            key2: value2

I want to do something like this:

for all tests as test:
  print test.name + test.key1

I have looked at JYaml and SnakeYaml but all they seem to do is map from YAML to Java objects. Is YAML not the right job for this? Is there a simple way to achieve this? all I need is to iterate through and get the values of each, kind of like a DOM traversal.

trinth
  • 5,919
  • 9
  • 40
  • 45

1 Answers1

1

Well I figured it out. I am using YamlBeans, which provides methods for this: https://github.com/EsotericSoftware/yamlbeans

Wilfred Hughes
  • 29,846
  • 15
  • 139
  • 192
trinth
  • 5,919
  • 9
  • 40
  • 45
  • 4
    SnakeYAML can parse it with 2 lines: Yaml yaml = new Yaml(); yaml.load(document); What are the methods in YamlBeams which are not available in SnakeYAML ? – Andrey Aug 06 '10 at 12:44