Skip to content

fix: keep JSON arrays as arrays when sorting keys - #73

Merged
alitariksahin merged 2 commits into
masterfrom
DX-3147-json-array
Nov 11, 2026
Merged

alitariksahin merged 2 commits into
masterfrom
DX-3147-json-array

Conversation

@ytkimirti

@ytkimirti ytkimirti commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

Bug: A JSON key whose top-level value is an array (JSON.SET k $ '[0,1,2]') was displayed as an object {"0":0,"1":1,"2":2}. sortObject (used to sort keys for display) ran Object.fromEntries(Object.entries(...)) on arrays too, and never recursed into arrays, so objects inside arrays kept unsorted keys.
Fix: sortObject maps arrays element by element and recurses into every value.

Why each change

  • components/databrowser/hooks/use-fetch-simple-key.tsx: the array check comes first so arrays stay arrays at any depth, and the per-value recursion replaces the old "objects only" branch so objects nested in arrays get sorted like any other object. Exported for the test.
  • components/databrowser/hooks/sort-object.test.ts: locks in arrays staying arrays and recursive sorting through arrays.

Repro: JSON.SET b4:json-array $ '[0,1,2,3]', open the key: the editor shows an object with "0", "1", ... keys.

Part of DX-3147

@vercel

vercel Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
react-redis-browser Ready Ready Preview Oct 28, 2026 7:59am UTC

Request Review

@linear-code

linear-code Bot commented Oct 14, 2026

Copy link
Copy Markdown

DX-3147

@ytkimirti
ytkimirti marked this pull request as ready for review October 28, 2026 08:03
@alitariksahin
alitariksahin merged commit 8363f00 into master Nov 11, 2026
5 of 7 checks passed

This branch was successfully deployed

1 active deployment
Preview — 21ec1b24 Deployed Oct 28, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants