Repository navigation
fix(jq): keep object keys in input order - #2577
Merged
Merged
Conversation
Real jq preserves object key order and only sorts under -S. Input went through serde_json::Value, whose map is sorted, so every printed object came out alphabetized. Deserialize straight into JqJson with an order-preserving, depth-checking seed for main input, --slurpfile, --argjson, --jsonargs and $ARGS. Claude-Session: https://claude.ai/code/session_01VscpEzxtqpCKx5eRMpywNj
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
bashkit | 2713974 | Commit Preview URL Branch Preview URL |
Oct 07 2026, 04:43 PM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Михайло · project thread
What changed
jqnow prints object keys in the order they appear in the input, the same as real jq. Keys are only sorted under-S. This applies to main input (stdin or files),--slurpfile,--argjson,--jsonargsand$ARGS. A duplicate key keeps its first position and takes the last value, also matching jq.Why
Input JSON went through
serde_json::Value, whose map is sorted, so every object bashkit printed came out alphabetized. Most agentjqcalls print objects, and a Debian-oracle differential run (pseudo-linus test bench) flagged this as the most common jq mismatch. We don't turn on serde_json's crate-widepreserve_orderfeature because that would change every otherserde_jsonuser in the workspace. Instead jq input is deserialized straight intoJqJsonwith an order-preserving seed. The seed checks nesting depth while reading, so the TM-DOS-027 limit still applies and its error message is unchanged.Before / After
The new
jq_object_key_order_*spec cases fail on main (3 of 5; the-Sand duplicate-key cases already passed) and all pass on this branch.Risk
-Sstill sorts.Checklist
convertunit tests for order, duplicate keys, depth, trailing garbage)$ENVstays sorted by name for determinism)https://claude.ai/code/session_01VscpEzxtqpCKx5eRMpywNj