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

ordering of keys #84

Closed
pkoppstein opened this issue Jul 9, 2021 · 2 comments
Closed

ordering of keys #84

pkoppstein opened this issue Jul 9, 2021 · 2 comments

Comments

@pkoppstein
Copy link

The README acknowledges the discrepancies between jq and gojq with respect to key ordering,
but there is no open "ticket" to track this issue, which I believe to be critical.
Having a ticket will also allow others to weigh in.

Based on my own personal experience and observations, I believe that one of jq's great strengths
(at least after jq 1.3) is that it supports the ordering of keys, while defining "object equality" without regard to key ordering.

The practical importance of supporting the ordering of keys is closely related to what I take to be
one of JSON's main goals -- to be readable and maintainable by humans.

@itchyny
Copy link
Owner

itchyny commented Jul 17, 2021

I understand the practical importance but unlikely to implement for now so closing. There are various difficulties here; no support in Go standard library, custom internal functions.

@ahochsteger
Copy link

@itchyny at least for a YAML roundtrip there would be support for ordered keys using MapSlice: https://pkg.go.dev/gopkg.in/yaml.v2#MapSlice
I've seen similar approaches to keep the order of keys using MapSlice for JSON too.
This is the last known issue to me to completely switch from jq to gojq.

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

Successfully merging a pull request may close this issue.

3 participants