Forum Discussion
The Lookup snaps are going to operate on documents and not arrays inside of documents. You could use a JSONSplitter snap to break up the array into multiple documents, but then you probably need to collect them back together to keep the original format, which can be difficult. It might be easier to use the expression language to perform the lookups.
Would you be able to restructure this source data so that it is more like an object? For example:
{
"abc" : {
"exp_time": "30s"
},
"xyz" : {
"exp_time": "20s"
},
...
}
If so, the lookup is then just a matter of getting the property from this object. If this JSON source data is static and in a file, you can import it via an expression library (see https://doc.snaplogic.com/wiki/spaces/SD/pages/1438110/Expression+Libraries).
For example, if you imported this source data as a library with the name ‘source’. You can then use a map() method to perform the transform on the array:
$.caseSteps.map(elem => elem.extend(lib.source[elem.code]))
This code will iterate over the the elements of the array using the map() method. For each element, it will execute the function that was passed in to create the new value for the element. The callback function looks up the data to add in to the object (lib.source[elem.code]) and then creates a new object from the existing one and the extra data (elem.extend()).