Skip to content

Insert empty value #740

Answered by mikefarah
sylvainbx asked this question in Q&A
Mar 1, 2021 · 1 comments · 3 replies
Discussion options

You must be logged in to vote

That empty value is null in yaml (one of the many ways you can represent null in yaml).

Whereas setting .a.d to "" sets it to the empty string.

To set it to null you can:

yq -i eval '.a.d = null' sample.yml

But then you will see null in .a.d's value. To get an empty (null) value, you can do this:

yq e -n '.a.d = "" | .a.d tag="!!null"'

Not as clean as v3 admittedly.

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@sylvainbx
Comment options

@sylvainbx
Comment options

@mikefarah
Comment options

Answer selected by sylvainbx
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