Skip to content

Duplicate map keys in the output #2221

Open
@Zebradil

Description

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
}

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions