admin管理员组文章数量:1403343
Given the following example:
.a: &a
sheep: "a"
.b : &b
cow: "a"
edileMamals: &edible_mamals
<< : *a
<< : *b
edibleAnimals: &edible_animals
mamals:
<< : *edible_mamals
fish:
salmon: "a"
tuna: "a"
I would like now to create allAnimals
that relies on edibleAnimals
and extends both mamals
and fish
. My naive approach of doing it like this:
allAnimals:
<< : *edible_animals
mamals:
horse: "a"
fish:
dolphin: "a"
got me:
allAnimals:
mamals:
horse: "a"
fish:
dolphin: "a"
instead of:
allAnimals:
mamals:
sheep: "a"
cow: "a"
horse: "a"
fish:
salmon: "a"
tuna: "a"
dolphin: "a"
I understand that the merge function sees that both edibleAnimals
and allAnimals
have the mamals
key, so it takes the later. But is there a way to perform a multilayer merge?
So far I only found an answer here that suggest to add extra code to support the "+" suffix operator as a workaround , but I'm looking for a generic/native solution.
Given the following example:
.a: &a
sheep: "a"
.b : &b
cow: "a"
edileMamals: &edible_mamals
<< : *a
<< : *b
edibleAnimals: &edible_animals
mamals:
<< : *edible_mamals
fish:
salmon: "a"
tuna: "a"
I would like now to create allAnimals
that relies on edibleAnimals
and extends both mamals
and fish
. My naive approach of doing it like this:
allAnimals:
<< : *edible_animals
mamals:
horse: "a"
fish:
dolphin: "a"
got me:
allAnimals:
mamals:
horse: "a"
fish:
dolphin: "a"
instead of:
allAnimals:
mamals:
sheep: "a"
cow: "a"
horse: "a"
fish:
salmon: "a"
tuna: "a"
dolphin: "a"
I understand that the merge function sees that both edibleAnimals
and allAnimals
have the mamals
key, so it takes the later. But is there a way to perform a multilayer merge?
So far I only found an answer here that suggest to add extra code to support the "+" suffix operator as a workaround , but I'm looking for a generic/native solution.
Share Improve this question asked Mar 20 at 12:49 Gleb NebolyubovGleb Nebolyubov 6765 silver badges14 bronze badges1 Answer
Reset to default 0After looking through the documentation of yaml I can say that at least by April 2025 "deep merge" or "nested merge" doesn't exist in yaml.
本文标签: Can I merge nested mappings in yamlStack Overflow
版权声明:本文标题:Can I merge nested mappings in yaml? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744408438a2604824.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论