Skip to content
Myr

Keep object keys in parsing order in `tostream` output

Before adoption: this commit came in with the history the project adopted, so no landing records it.

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.

authored by Eric Bréchemier · committed by Nico Williams · parent 239278f · Browse files · 2 files+2 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+2 added−1 removed

  • other:+2 added−1 removed

2 files+2 added−1 removed

modified:src/builtin.jq+1 added-1 removed
235 unmodified lines
236 if $leaf_types[$dot|type] or length==0 then [[],$dot]237 else238 # We really need a _streaming_ form of `keys`.239 # We can use `range` for arrays, but not for objects.240 keys as $keys |240 keys_unsorted as $keys |241 $keys[-1] as $last|242 ((# for each key243 $keys[] | . as $key |244 $dot[$key] | . as $dot |
64 unmodified lines
modified:AUTHORS+1 added
22 unmodified lines
23David R. MacIver <david@drmaciver.com> - bug fixes24David Tolnay <dtolnay@gmail.com> - destructuring, build improvements25Doug Luce <doug@github.con.com> - build26Eiichi Sato <sato.eiichi@gmail.com>27Eric Bréchemier <eric@egull.co> - bug fix28Filippo Giunchedi <fgiunchedi@gmail.com> - bug fixes29Filippo Valsorda <filippo.valsorda@gmail.com> - recursive object merge (`*`)30Hanfei Shen <qqshfox@gmail.com>31i <isomorphisms@sdf.org>
42 unmodified lines