Diff filter doesn't work on object arrays?
Options
Nathan Cox
Member ✭
[Screen Recording 2022-09-21 at 14.07.26.mov]I have two JSON arrays, and I'm trying to use the diff function to identify unique objects in the array.
This works fine on a simple array of numbers, but on an array of objects, it says "an unknown error has occurred"
Please see the video attached. First I show you that both datasets are formatted the same. Secondly, I activate the 'diff' filter and the error occurs.
Any help would be appreciated thanks!
This works fine on a simple array of numbers, but on an array of objects, it says "an unknown error has occurred"
Please see the video attached. First I show you that both datasets are formatted the same. Secondly, I activate the 'diff' filter and the error occurs.
Any help would be appreciated thanks!
Comments
-
Diff filter doesn't work on objects. This is true in a lot of languages because of how objects (and vector data types generally) are stored in memory.
So to figure out "what's new" you'd need to roll your own.
How I would think about it: loop over the objects to build parallel arrays of JSON strings. Then diff the arrays of strings (because strings can be diffed). Take the resulting exclusionary set, loop over it to decode the json from each element and add those to arrays. Boom, you have your diffed array. -
we'll check out the error. It feels like this should be supported. We definitely should have a better error message though. Will let you know what we find.
-
Incredible thanks.
-
Hey thanks for your patience on this. We've updated to add support for diffs and intersections on arrays to work with nested objects instead of only scalars. Thanks for reporting this!
-
Thanks for this Chris, it does work now but I was hoping to return the whole object where the difference is, rather than just the key value from that object that changed. Is that possible? Thanks
-
I totally agree with Nathan, @Chris Coleman. A user expects to get the full object using the diff filter. I was trying to find the error for an hour until I stumbled over this old thread.
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