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

Duplicate map keys in the output #2221

Open
Zebradil opened this issue Dec 8, 2024 · 0 comments
Open

Duplicate map keys in the output #2221

Zebradil opened this issue Dec 8, 2024 · 0 comments
Labels

Comments

@Zebradil
Copy link

Zebradil commented Dec 8, 2024

Describe the bug

yq outputs duplicate keys when there are duplicate keys in the input.

Version of yq: 4.44.6
Operating system: mac
Installed via: binary release

Input Yaml

data1.yml:

{"foo":1,"foo":2}

Command

yq . data.yaml

Actual behavior

{"foo": 1, "foo": 2}

Expected behavior

{"foo": 2}

Additional context

yq outputs duplicate keys when there are duplicate keys in the input:

$ echo '{"foo":1,"foo":2}' | ./yq_darwin_arm64
{"foo": 1, "foo": 2}

$ echo '{"foo":1,"foo":2}' | ./yq_darwin_arm64 -P
"foo": 1
foo: 2

$ ./yq_darwin_arm64 --version
yq (https://github.com/mikefarah/yq/) version v4.44.6

jq removes duplicates, keeping the last value:

$ echo '{"foo":1,"foo":2}' | jq
{
  "foo": 2
}
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

1 participant