Reputation: 161
JSONata has the $keys() function which returns all the names associated with an object. I am trying to recursively apply this in order to return all of the object names that exist in a JSON tree.
This example returns the object names in nested arrays.
In an attempt to eliminate the array nesting I came up with this query ... which seems to work fine.
However, when I apply the exact same query to different JSON data as shown here the results are not fully flattened.
Q: What is the proper way to construct this query so that the results are fully flattened?
and/or
Q: What characteristic distinguishes these two datasets to account for the difference in the structure of the results?
Upvotes: 0
Views: 1212
Reputation: 161
OK, I guess I figured this out.
This query uses explicit calls to $map() and $reduce()+$append() to flatten it.
This query accomplishes the same thing using more a standard JSONata dot (.) query notation.
Upvotes: 0