YAML: mixing inline with regular map for same object

时间:2019-04-16 22:15:11

标签: yaml

Is it possible to mix an inline (json-like) map with regular map definitions for the same object?

Consider the following example:

person: {age: 32, weight: 82}
  name: foo

The resulting person should have the given age, weight, and name.

EDIT: moved my solution to an answer

1 个答案:

答案 0 :(得分:1)

可以通过使用合并标签:

person: 
  <<: {age: 32, weight: 82}
  name: foo

结果是:

{
  "person": {
    "age": 32, 
    "name": "foo", 
    "weight": 82
  }
}