]> granicus.if.org Git - jq/commitdiff
Keep object keys in parsing order in `tostream` output
authorEric Bréchemier <eric@egull.co>
Wed, 29 Nov 2017 17:26:56 +0000 (18:26 +0100)
committerNico Williams <nico@cryptonector.com>
Wed, 29 Nov 2017 17:46:08 +0000 (11:46 -0600)
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
src/builtin.jq

diff --git a/AUTHORS b/AUTHORS
index e64a2358f8aa1de787a2697584f7dee1edce0a00..65d6f5837dbcdf10ef3f0ab3bb7c582fdd7730ec 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -24,6 +24,7 @@ David R. MacIver     <david@drmaciver.com>            - bug fixes
 David Tolnay         <dtolnay@gmail.com>              - destructuring, build improvements
 Doug Luce            <doug@github.con.com>            - build
 Eiichi Sato          <sato.eiichi@gmail.com>
+Eric Bréchemier      <eric@egull.co>                  - bug fix
 Filippo Giunchedi    <fgiunchedi@gmail.com>           - bug fixes
 Filippo Valsorda     <filippo.valsorda@gmail.com>     - recursive object merge (`*`)
 Hanfei Shen          <qqshfox@gmail.com>
index 9c543a936bcb2f81e185867604f0a691be94d364..b0e8775ac599b71a1615f047d04bdae759b94f5e 100644 (file)
@@ -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 |