You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is good as a default, as it doesn't lose any information, and one can filter out those null top-level values if they wish to. However, when dealing with other tools which produce YAML like this, it can be a pain point to have to do this filtering as an extra step.
We propose adding options to the YAML encoding: omitempty would skip over documents in a stream which are empty (or only comments), and omitnull would skip over documents in a stream which are empty or the null value, as they are both equally null.
It is possible that such options could also be added to other streaming encodings, although right now I can't think of any. JSONL or NDJSON, for example, does technically map each line to one JSON value - but we currently skip over empty lines due to how Go's encoding/json decoder works, so it's as if omitempty were always set, as we don't fail on empty lines.
The text was updated successfully, but these errors were encountered:
As #3464 points out, it is possible for YAML files to include empty or null documents:
Currently, both are mapped to a
null
value:This is good as a default, as it doesn't lose any information, and one can filter out those null top-level values if they wish to. However, when dealing with other tools which produce YAML like this, it can be a pain point to have to do this filtering as an extra step.
We propose adding options to the YAML encoding:
omitempty
would skip over documents in a stream which are empty (or only comments), andomitnull
would skip over documents in a stream which are empty or thenull
value, as they are both equally null.Then, one could do, for example:
It is possible that such options could also be added to other streaming encodings, although right now I can't think of any. JSONL or NDJSON, for example, does technically map each line to one JSON value - but we currently skip over empty lines due to how Go's
encoding/json
decoder works, so it's as ifomitempty
were always set, as we don't fail on empty lines.The text was updated successfully, but these errors were encountered: