Json response sorting and editing

Options

Hello Community

  1. 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 :)
  2. 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

  • Ray Deck
    Ray Deck Trusted Xano Expert ✭✭✭
    Options

    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.