用于创建此数组的 Yaml 语法
Yaml syntax to create this array
给定以下简单的 yaml 数据,
foo: 1
bar:
- one
- two
如果我想创建一个数据结构完全相同的数组,正确的方法是什么?
我试过了
first:
foo: 1
bar:
- one
- two
- three
second:
foo: 2
bar:
- one1
- two2
- three3
或者,
- foo: 1
bar:
- one
- two
- three
- foo: 2
bar:
- one1
- two2
- three3
还有,
- first:
foo: 1
bar:
- one
- two
- three
- second:
foo: 2
bar:
- one1
- two2
- three3
但 none 似乎是正确的方法。有什么帮助吗?谢谢!
我想你是在追求这个:
- foo: 1
bar:
- one
- two
- three
- foo: 2
bar:
- one1
- two2
- three3
这给了你这个结构:
[
{
"foo": 1,
"bar": [
"one",
"two",
"three"
]
},
{
"foo": 2,
"bar": [
"one1",
"two2",
"three3"
]
}
]
或者,如果 'first' 和 'second' 标签对您很重要:
first:
foo: 1
bar:
- one
- two
- three
second:
foo: 2
bar:
- one1
- two2
- three3
这给你一个 dictionary/associative 数组:
{
"second": {
"foo": 2,
"bar": [
"one1",
"two2",
"three3"
]
},
"first": {
"foo": 1,
"bar": [
"one",
"two",
"three"
]
}
}
给定以下简单的 yaml 数据,
foo: 1
bar:
- one
- two
如果我想创建一个数据结构完全相同的数组,正确的方法是什么?
我试过了
first:
foo: 1
bar:
- one
- two
- three
second:
foo: 2
bar:
- one1
- two2
- three3
或者,
- foo: 1
bar:
- one
- two
- three
- foo: 2
bar:
- one1
- two2
- three3
还有,
- first:
foo: 1
bar:
- one
- two
- three
- second:
foo: 2
bar:
- one1
- two2
- three3
但 none 似乎是正确的方法。有什么帮助吗?谢谢!
我想你是在追求这个:
- foo: 1
bar:
- one
- two
- three
- foo: 2
bar:
- one1
- two2
- three3
这给了你这个结构:
[
{
"foo": 1,
"bar": [
"one",
"two",
"three"
]
},
{
"foo": 2,
"bar": [
"one1",
"two2",
"three3"
]
}
]
或者,如果 'first' 和 'second' 标签对您很重要:
first:
foo: 1
bar:
- one
- two
- three
second:
foo: 2
bar:
- one1
- two2
- three3
这给你一个 dictionary/associative 数组:
{
"second": {
"foo": 2,
"bar": [
"one1",
"two2",
"three3"
]
},
"first": {
"foo": 1,
"bar": [
"one",
"two",
"three"
]
}
}