Embedding JSON Data into YAML file

Saurajeet picture Saurajeet · Mar 2, 2012 · Viewed 50.5k times · Source

I am writing a fixture for my table. And a one of the coloums takes in a JSON string as a value.

The problem is the fixture is not loading failing as:

Fixture::FormatError: a YAML error occurred parsing /home/saurajeet/code/dcbox/test/fixtures/hardware.yml. Please note that YAML must be consistently indented using spaces. Tabs are not allowed. Please have a look at http://www.yaml.org/faq.html
The exact error was:
  ArgumentError: syntax error on line 145, col 73: `  portslist: [{"name":"ob1","port_num":0,"port_type":"network"},{"name":"ob2","port_nu'.....

Any solutions to this.

Answer

Vlad Khomich picture Vlad Khomich · Mar 2, 2012

I believe taking it into quotes should do the trick:

portslist: '[{"name":"ob1","port_type" ... }]'