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

Deeply nested JSON values are rearranged by json.set #4397

Open
rabinnh opened this issue Jan 2, 2025 · 3 comments
Open

Deeply nested JSON values are rearranged by json.set #4397

rabinnh opened this issue Jan 2, 2025 · 3 comments
Labels
bug Something isn't working

Comments

@rabinnh
Copy link

rabinnh commented Jan 2, 2025

Describe the bug
While I can't provide a sample at this time, storing a complex JSON document using:

json.set key $ '{.......}'

Rearranges the document.

To Reproduce
I will try to create a sample JSON document that isn't proprietary to follow up later.

Expected behavior
Redis stores the document exactly as set.

Environment (please complete the following information):

  • OS: [ubuntu 22.04]
  • Kernel: Linux silverspore-host 6.8.0-49-generic Fix info command to use git version #49~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov 6 17:42:15 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
  • Containerized?: Yes, using docker compose and docker.dragonflydb.io/dragonflydb/dragonfly
  • Dragonfly Version: df-v1.25.1

Reproducible Code Snippet

# Minimal code snippet to reproduce this bug

Additional context

@rabinnh rabinnh added the bug Something isn't working label Jan 2, 2025
@romange
Copy link
Collaborator

romange commented Jan 3, 2025

Sorry, I do not consider it a bug unless you prove that arrays are rearranged. For key/value objects - the spec does not guarantee order and Redis's behavior is implementation specific. Please do not rely on it.

@rabinnh
Copy link
Author

rabinnh commented Jan 3, 2025

I assume that you're referring to the json spec? Can you please provide the reference? JSON is sometimes used to back a user interface in which case the order can be critical.

I suppose I could stop using json.set and just use set and save it as a string blob.

@romange
Copy link
Collaborator

romange commented Jan 3, 2025

See https://stleary.github.io/JSON-java/index.html for example: A JSONObject is an unordered collection of name/value pairs...
yes, you can save as string. I submitted #4399 to allow querying strings json objects using json.get

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants