Closed lpellegr closed 4 years ago
This behavior is correct, and your expectation to get an empty object is not correct. An empty YAML document gets loaded as a null scalar, which is equivalent to JSON. You can use the object literal {}
to get an empty object in YAML. Why does the command output not make sense to you?
Most probably my lack of knowledge about YAML. Thanks for the clarification.
While using yq (version
2.10.1
) to convert several files, I noticed that an empty YAML file produces an empty JSON file while I was expecting{}
as JSON.The command used is the following:
I am not sure it can be considered as a bug since the JSON grammar allows an empty object or array as root. As a consequence, I was wondering if there an equivalent to an empty object (
{}
) in YAML so that once passed toyq
, the output is{}
?The command
echo "{}" | yq -y .
returns{}
, which does not seem to make sense.