upstash / react-ui

Various react components from our console
https://react-ui-upstash.vercel.app
19 stars 1 forks source link

Data Browser does not preserve order of elements in JSON arrays #49

Open t4top opened 7 months ago

t4top commented 7 months ago

Issue: Data Browser UI does not preserve order of elements in JSON arrays

How to reproduce:



**Result:** The CLI output is correct, but the Data Browser has the array sorted and does not preserve order of array elements.

**Expected:** The order of elements in JSON arrays must be preserved. According to [RFC 7159 -The JavaScript Object Notation (JSON) Data Interchange Format](https://www.rfc-editor.org/rfc/rfc7159.html), an array is an **ordered** sequence of zero or more values.

**Screenshots:**
![cli](https://github.com/upstash/react-ui/assets/45775673/d93f94b6-082d-47ba-a539-fb8c9a062ac2)
![databrowser](https://github.com/upstash/react-ui/assets/45775673/70f53af0-2a7b-4a6d-b3ad-8ca0947f25b4)
ogzhanolguncu commented 7 months ago

We have a custom function that sorts key-values in lexical order. But if this is bothering you so much I can think a way to do this differently.

t4top commented 7 months ago

Thanks for your response. The ordering of Object keys is fine, but there's an issue with Arrays. It might be confusing when setting an array like [2,1] and seeing [1,2] in the UI, as we all know [2,1] != [1,2].

Could you consider adding a switch in the UI to enable/disable your custom lexical sorting (for arrays)? This way, users can choose between a lexical order or a raw output without reordering. Please, ensure that the user's choice remains persistent across sessions.

ogzhanolguncu commented 7 months ago

Sure. I'll see what I can do.