Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Yaml hierarchical data

Tags:

yaml

I'd like to represent a hierarchy in yaml, and I'm not sure how. For example, I'd like to say something like this:

name: "user1"
programming-skill: 3
    java: 2
    python: 2
cooking-skill: 4

When I throw this at a yaml parser, I get an error along the lines of "mapping values not allowed here" on the line java: 2 because I'm trying to assign programming-skill to both 3 and the list {java: 2, python: 2}.

What's the cleanest way to represent this hierarchical structure in yaml? Alternatively, is there a serialization format more suited than yaml to hierarchical structures?

like image 915
So8res Avatar asked Jun 15 '11 05:06

So8res


1 Answers

name: "user1"
programming-skill: 
  - 3
  - java: 2
    python: 2
cooking-skill: 4

or if you prefer:

name: "user1"
programming-skill: 
  - 3
  - 
    java: 2
    python: 2
cooking-skill: 4
like image 124
Philip Durbin Avatar answered Nov 15 '22 10:11

Philip Durbin