Json response sorting and editing
![Valentin R](https://us.v-cdn.net/6037124/user_avatars/4304535.jpg)
Hello Community
- Is there any way to manipulate the order of items in a json response? E.g. I use "set" filter to add an item and a new path+value is added at the bottom of json and I wish it was at the top. Oooh yes, I want it pretty :)
- Can I update an existing path of an item in json? I am currently doing "set" and "unset" to work around, but it seems excessive.
Thanks!
Answers
-
JSON objects (key-value pairs) have fidelity of association but not of order. Similarly, arrays (lists) have fidelity of order but no association. There can be tweaks to get the objects in a certain order accidentally, but that order is not guaranteed to persist across various operations.
As for changing a path, all tree management libraries that I know of allow mutation of value but not of path. Changing the path requires detaching the leaf and attaching it elsewhere. I can imagine creating a function to paper over this mechanic, giving you the experience of "set path A to B in object X" but I do a lot of data work and it's never come up for me to my recollection.
I love the questions! Weird data manipulation is definitely my jam.
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback