From: Eric Bréchemier Date: Wed, 29 Nov 2017 17:26:56 +0000 (+0100) Subject: Keep object keys in parsing order in `tostream` output X-Git-Tag: jq-1.6rc1~7 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=476b36770d933738130880bc6f30751cdf880aed;p=jq Keep object keys in parsing order in `tostream` output As noted by @nicowilliams, `tostream` used `keys`, which sorts the keys in alphabetical order, instead of `keys_unsorted`, which preserves the parsing order. Fixes #1541. --- diff --git a/AUTHORS b/AUTHORS index e64a235..65d6f58 100644 --- a/AUTHORS +++ b/AUTHORS @@ -24,6 +24,7 @@ David R. MacIver - bug fixes David Tolnay - destructuring, build improvements Doug Luce - build Eiichi Sato +Eric Bréchemier - bug fix Filippo Giunchedi - bug fixes Filippo Valsorda - recursive object merge (`*`) Hanfei Shen diff --git a/src/builtin.jq b/src/builtin.jq index 9c543a9..b0e8775 100644 --- a/src/builtin.jq +++ b/src/builtin.jq @@ -237,7 +237,7 @@ def tostream: else # We really need a _streaming_ form of `keys`. # We can use `range` for arrays, but not for objects. - keys as $keys | + keys_unsorted as $keys | $keys[-1] as $last| ((# for each key $keys[] | . as $key |