Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-p yaml and -p json do not behave the same, but --help implies that they do. #1990

Closed
lhmathies opened this issue Mar 22, 2024 · 1 comment
Closed
Labels

Comments

@lhmathies
Copy link

Describe the bug

Version of yq: 4.35.2

Operating system: windows/

Input Json
"foo"
"bar"

Command
The command you ran:

$ yq eval --help | grep input-format
  -p, --input-format string           [auto|a|yaml|y|props|p|xml|x|tsv|t|csv|c|toml] parse format for input. Note that json is a subset of yaml. (default "auto")
$ echo $'"foo"\n"bar"' | yq -p json -o json
"foo"
"bar"
$ echo $'"foo"\n"bar"' | yq -p auto -o json
"foo"
Error: bad file '-': yaml: line 1: did not find expected <document start>

Expected behavior
-p json is not expected to make a difference, or indeed to be accepted, according to the help text. If you ask me, a sequence of JSON objects should be parsed under -p auto, even without YAML document separators.

Additional context
The difference is of course that -p json does not insist on YAML document separators. This should be documented.

@mikefarah
Copy link
Owner

This has been updated in the later versions of yq

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants