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

问题是fixture 没有加载失败,因为:

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.

推荐答案

I believe taking it into quotes should do the trick:

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

Json相关问答推荐

Elasticsearch Go客户端错误:无效的SON格式:在中间件中索引文档时出错

使用动态和可变JSON的图表多条

过go 24小时内判断员事件的EventBridge事件模式

如何判断响应数组是否存在以及S是否有其他内容...?

使用Kotlin限制序列化类属性的允许整数值

如何使用jq使用子值对象的键对json对象进行分组

删除 JOLT 中的方括号

Delphi 11.3无法从变体创建/添加JSON

shell解析json并循环输出组合变量

Oracle Apex - 将 JSON 对象分配给变量以返回

如何在linux中用jq过滤json数组?

传统编程语言等价于动态 SQL

jq搜索特定字符串并输出对应的父值

Jolt - 在同一级别添加时组合值的问题

避免 KeyError 的默认字典键

如何获取json格式的KendoGrid显示数据?

如何为名称/值 struct 创建 JSON 模式?

python追加到json对象中的数组

使用新的 Net Core 3.0 Json 时忽略属性

仅使用字符串和值解析 JSON 对象