英文:
YAML - Is there a difference between these two mapping structures?
问题
我相信以下两种结构是指定映射的等效方式。
environment:
VARIABLE_1: value1
VARIABLE_2: value2
environment:
- VARIABLE_1=value1
- VARIABLE_2=value2
我相信这两种方式都应该是指定映射的等效方式,以JSON格式表示如下:
{
"environment" : {
"VARIABLE_1" : "value1",
"VARIABLE_2" : "value2"
}
}
我的理解是否正确?
因为我不太了解术语,所以无法通过DuckDuckGo或其他搜索引擎来搜索答案。
不过,我确实查看了文档,没有发现明显的信息。
英文:
I believe the following two structures are equivalent ways of specifying a map.
environment:
VARIABLE_1: value1
VARIABLE_2: value2
environment:
- VARIABLE_1=value1
- VARIABLE_2=value2
I believe both of these should be equivalent ways of specifying a map, which in JSON format would be this:
{
"environment" : {
"VARIABLE_1" : "value1",
"VARIABLE_2" : "value2"
}
}
Is my understanding correct?
Because I do not know the terminology in detail I could not perform a search to find an answer via duckduckgo or other search engine.
I did however scan the docs and nothing obvious jumped out at me.
答案1
得分: 1
第一个是类似Python中的字典或Golang中的映射,第二个是类似Python中的列表或Golang中的切片。你的JSON等价于第一个YAML示例。你的第二个YAML示例会类似于以下内容:
{
"environment": [
"VARIABLE_1=value1",
"VARIABLE_2=value2"
]
}
英文:
no, first one is a like a dictionary in python or map in golang or ... in ... . second one is a like a list in python or a slice in golang or ... in ... . your json is equivalent version of map(first yaml example). your second yaml example would be something like this:
{
"environment": [
"VARIABLE_1=value1",
"VARIABLE_2=value2"
]
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论