-
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
-
SaaSHub
SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives
-
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
-
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
-
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
-
-
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())"