添加列表时出现yaml语法错误

时间:2016-10-06 23:16:35

标签: yaml

我正在尝试为对象列表生成yaml,并且我收到错误声明错误的语法

tables:
 table_ab:
  bankspecificparams:
  -
     issuer:"bank1"
     cardname:""
     expiredinterval:"90d"
     fields:
      - "a"
      - "b"
  -
     issuer:"bank2"
     cardname:""
     expiredinterval:"40d"
     fields:
      - "a"
      - "b"  
  - 
     issuer:"bank3"
     cardname:"name1"
     expiredinterval:"40d"
     fields:
      - "a"
      - "b"

以下yaml snytax似乎不正确。我不确定这里有什么问题。

1 个答案:

答案 0 :(得分:0)

这是冒号后空格的问题。

tables: 
  table_ab: 
    bankspecificparams: 
      - 
        cardname: ""
        expiredinterval: 90d
        fields: 
          - a
          - b
        issuer: bank1
      - 
        cardname: ""
        expiredinterval: 40d
        fields: 
          - a
          - b
        issuer: bank2
      - 
        cardname: name1
        expiredinterval: 40d
        fields: 
          - a
          - b
        issuer: bank3

添加空格解决了问题