Json key randomize order after save ? #3612
Replies: 6 comments
-
Can you provide more detail here? Is the JSON data itself changing 'order'? If you could include screenshots of what you are seeing / what you would expect, that would be super helpful. |
Beta Was this translation helpful? Give feedback.
-
Hey @hotrungnhan — unfortunately because we save JSON, and not a string, in the database, keys within JSON have no inherent way of ordering themselves and there's nothing we can do to enforce their key order. This is a limitation of object properties in both JS and in JSON which Payload can't do much about. Sorry about the hassle here! |
Beta Was this translation helpful? Give feedback.
-
Luckily Mongodb have preserse the order. |
Beta Was this translation helpful? Give feedback.
-
Hmmmm very interesting! good find! Would you be willing to implement that package as a PR? We would happily accept that! Good find! This file is where it would need to be leveraged (you can see that we JSON.parse and JSON.stringify in this file): |
Beta Was this translation helpful? Give feedback.
-
Can you reopen the issue. I gonna try this weekend |
Beta Was this translation helpful? Give feedback.
-
Yes, but I'll convert this to a feature request discussion and add it to a roadmap to more accurately reflect its nature. THANK YOU!!! |
Beta Was this translation helpful? Give feedback.
-
Link to reproduction
Update later
To Reproduce
Describe the Bug
My expectation is keep the json schema the same as we type, without changing the order.
It will be better if we have a flag to disable behavious.
Payload Version
1.15.2
Beta Was this translation helpful? Give feedback.
All reactions