Gojq: Pure Go Implementation of Jq

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

Our great sponsors
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • SaaSHub - Software Alternatives and Reviews
  • gojq

    Pure Go implementation of jq

  • I don't think the distinction you're trying to make is helpful here if I've understood you correctly. A good faith interpretation of haastad's comment would be that they were thinking of "insertion order" when they said "a deterministic ordering". Even if we were being pedantic, their comment is still correct - for iteration order to be the same as input order then deterministic iteration ordering isn't sufficient (this seems to be the point you're making) but it is necessary.

    Their first sentence:

    > I bet it's an artifact of Go having a randomized iteration order over maps

    is correct per Gojq's author [0]:

    > gojq cannot implement keys_unsorted function because it uses map[string]interface{} to represent JSON object so it does not keep the order. Currently there is no plan to implement unordered map so I do not implement this function.

    It would be possible to work around this limitation of Go's built-in map type but that's not the point. The author makes it clear that this limitation is the cause for the tool's behaviour.

    [0] https://github.com/itchyny/gojq/issues/50

  • go

    The Go programming language

  • Go actually went in the other direction for a bunch of reasons (e.g. hash collision dos) and made key order quasi-random when iterating. Small maps used to maintain order, but a change was made to randomize that so people didn't rely on that and get stung when their maps got larger: https://github.com/golang/go/issues/6719

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
  • query-json

    Faster, simpler and more portable implementation of `jq` in Reason

  • It's very possible it could be faster; jq seems to actually be fairly unoptimized. This implementation in OCaml was featured on HN a while back and it trashes the original jq in performance: https://github.com/davesnx/query-json

    After seeing that one I did my own (less-complete) version in Rust and managed to squeeze out even more performance: https://github.com/brundonsmith/jqr

  • jqr

  • It's very possible it could be faster; jq seems to actually be fairly unoptimized. This implementation in OCaml was featured on HN a while back and it trashes the original jq in performance: https://github.com/davesnx/query-json

    After seeing that one I did my own (less-complete) version in Rust and managed to squeeze out even more performance: https://github.com/brundonsmith/jqr

  • hashmap

    A Golang lock-free thread-safe HashMap optimized for fastest read access.

  • pq

    Like jq, but with Python (by dvolk)

  • Why use a special syntax that's hard to remember when you can just use Python?

    I wrote a jq-like that accepts Python syntax called pq: https://github.com/dvolk/pq

    So you can write stuff like:

        $ echo '{ "US": 3, "China": 12, "UK": 1 }' | pq -c "sum(data.values())"

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts