I’m running a program in Ruby on Rails and have an array of hashes set up in YAML. I’m getting an ArgumentError apparently for having an opening curly brace on the same line as a closing brace for the previous hash.
For example, I have:
features: [
{
name: lorem ipsum,
bullets: [
"bullet 1",
"bullet 2"
]
},{
name: lorem ipsum 2,
bullets: [
...
}
]
and it gives me the error. However when I place the opening curly brace on a new line like so:
},
{
name: lorem ipsum 2,
...
it works fine.
I’m using Ruby v. 1.8.7, Rails v. 3.2.1 and Rails Config v. 0.2.4 to read in the YAML file and access it in my app.
Any ideas how to make YAML accept my syntax without doing it the latter way?
YAML doesn’t use braces, brackets, etc. Instead, everything will already parse as a hash as-is, and you only need to insert hyphens in front of your list items:
Loading this will give you: