Skip to content

Preserve LHS quotes when converting to properties style #818

Answered by mikefarah
geekosphere-net asked this question in Q&A
Discussion options

You must be logged in to vote

The quotes on that key are part of the yaml formatting style as opposed to the value - so they do not come through when processing the data.

The closest I can get is to wrap all the properties:

yq eval '.. | select((tag == "!!map" or tag == "!!seq") | not) | (path | .[] |= sub("(.*)", "\"${1}\"") | join(".")) + "=" + .' examples/data1.yaml

to get:

"one"."two.three"."four"=five

Not sure if that helps?

Note that this requires v4.9.1 to be able to escape double quotes in a double quoted string.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@mikefarah
Comment options

@geekosphere-net
Comment options

Answer selected by geekosphere-net
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants