Syntax for empty dictionary in YAML

前端 未结 2 857
没有蜡笔的小新
没有蜡笔的小新 2021-02-04 22:46

How do I denote an empty dictionary in YAML? I.e. it should be semantically equivalent to the empty json-object {}.

2条回答
  •  醉梦人生
    2021-02-04 23:27

    Short answer: use {}

    There are two ways to denote mappings (dictionaries) in yaml; flow mappings and block mappings:

    block_mapping:
        name:  foo
        id:    bar
    flow_mapping: { name: foo, id: bar }
    empty_flow_mapping: {}
    

    The flow mapping style is thus suitable for representing empty mappings.

提交回复
热议问题