YAML 中空字典的语法 [英] Syntax for empty dictionary in YAML

查看:31
本文介绍了YAML 中空字典的语法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 YAML 中表示空字典?IE.它应该在语义上等同于空的 json-object {}.

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

推荐答案

简短回答:使用 {}

yaml中有两种表示映射(字典)的方式;流映射块映射:

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.

这篇关于YAML 中空字典的语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆