From 476b36770d933738130880bc6f30751cdf880aed Mon Sep 17 00:00:00 2001 From: =?utf8?q?Eric=20Br=C3=A9chemier?= Date: Wed, 29 Nov 2017 18:26:56 +0100 Subject: [PATCH] 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. --- AUTHORS | 1 + src/builtin.jq | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) 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 | -- 2.40.0