Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
t4top opened this issue Dec 3, 2023 · 3 comments
Open

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

t4top opened this issue Dec 3, 2023 · 3 comments

Comments

@t4top
Copy link

t4top commented Dec 3, 2023

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

How to reproduce:

  • Add a JSON entry with the following command.
JSON.SET doc $ '{"a":['2','1']}'
  • Read back the JSON entry on both CLI and via the Data Browser UI.
  • The CLI shows below, which is correct.
> JSON.GET doc
{"a":[2,1]}
  • The Data Browser shows below, which has the array sorted and it is wrong.
{
  "a": [
    1,
    2
  ]
}

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, an array is an ordered sequence of zero or more values.

Screenshots:
cli
databrowser

@ogzhanolguncu
Copy link
Contributor

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
Copy link
Author

t4top commented Dec 4, 2023

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
Copy link
Contributor

Sure. I'll see what I can do.

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

No branches or pull requests

2 participants