How to style a map key #1678
-
yq version info Version of yq: 4.25.2 Describe the bug I have a yaml which has a map with quoted keys. I would like to add new key-value pairs to the yaml with double quoted keys. Input Yaml features:
"f1": true
"f2": true What i want to add is another key: "f3" to the map with value true (without any quotes). Is that possible? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Yep - you can use the "key" operator to work with the key of a map. To set the style of the key you can:
This can be put together with assigning the value
Hope that makes sense! |
Beta Was this translation helpful? Give feedback.
Yep - you can use the "key" operator to work with the key of a map. To set the style of the key you can:
This can be put together with assigning the value
true
usingwith
with
changed the context to.feaures.f3
. = true
, the.
refers to the current node, which is the valuekey style= "double"
,key
will get the key node of the value,style=
will update the styleHope that makes sense!