B
basi
Hello,
How does one tell YAML to use an array substructure rather than a hash?
Given the following YAML data:
an:
- at sf
- fc di
- ps:
- na vb
- ex anEx
- ps:
- na no
- ex otherEx
- pr pro
in:
- at sf
- fc lo
YAML gives it the structure: {[{[...]}]}, that is, Hash embeds Array
which embeds another Hash which embeds Array, as below (output
reformatted for clarity).
{"an"=>
[ "at sf",
"fc di",
{"ps"=>
["na vb",
"ex anEx"]},
{"ps"=>
["na no",
"ex otherEx",
"pr pro"]}],
"in"=>
["at sf",
"fc lo"]
}
I feel that the structure below: {[[[...]]]}, that is, hash embeds
array which embeds another array makes it easier to pick off keys and
values than the other structure (though, honestly, I haven't gone that
far yet).
{"an"=>
[ "at sf",
"fc di",
"ps"=>
["na vb",
"ex anEx"]],
"ps"=>
["na no",
"ex otherEx",
"pr pro"]]],
"in"=>
["at sf",
"fc lo"]
}
Thanks for the help.
basi
How does one tell YAML to use an array substructure rather than a hash?
Given the following YAML data:
an:
- at sf
- fc di
- ps:
- na vb
- ex anEx
- ps:
- na no
- ex otherEx
- pr pro
in:
- at sf
- fc lo
YAML gives it the structure: {[{[...]}]}, that is, Hash embeds Array
which embeds another Hash which embeds Array, as below (output
reformatted for clarity).
{"an"=>
[ "at sf",
"fc di",
{"ps"=>
["na vb",
"ex anEx"]},
{"ps"=>
["na no",
"ex otherEx",
"pr pro"]}],
"in"=>
["at sf",
"fc lo"]
}
I feel that the structure below: {[[[...]]]}, that is, hash embeds
array which embeds another array makes it easier to pick off keys and
values than the other structure (though, honestly, I haven't gone that
far yet).
{"an"=>
[ "at sf",
"fc di",
"ps"=>
["na vb",
"ex anEx"]],
"ps"=>
["na no",
"ex otherEx",
"pr pro"]]],
"in"=>
["at sf",
"fc lo"]
}
Thanks for the help.
basi