Forum Discussion
Without giving you the answer outright 😉, did you look at the Array.map() function?
https://docs-snaplogic.atlassian.net/wiki/spaces/SD/pages/1438091/Array+Functions+and+Properties#ArrayFunctionsandProperties-map
Also see the very bottom of this page for a similar example:
https://docs-snaplogic.atlassian.net/wiki/spaces/SD/pages/1438042/Understanding+Expressions+in+SnapLogic
Yes but .map() function transforms every element from the Array, I only need to change the fields where there are numbers. Is there a way that I can use conditional logic inside of the .map() function?( if typeof value == ‘number’ then value * 10 else value
nickhumble - my apologies - I missed your original response to my question.
If there are two input documents that you want to combine to a single document, I would recommend using the Gate snap in this case. Then follow with a Mapper snap with the following expression:
The jsonPath is a powerful function that allows you to rip through a JSON structure looking for specific sub-elements easily and return the results as an array. This specific syntax tells jsonPath to return all elements buried under the top three arrays.
Note that the Gate snap has some considerations when processing larger volumes of data, but for this case, it works very nicely. Also, the jsonPath documentation has some external links for additional details of how you can work with it along with some good examples.
Hope this helps!
- nickhumble2 years agoNew Contributor II
Thanks Koryknick - this has worked for me. My dataset is larger than what i shared but not enormous and i think should be ok.
nickhumble - the input you have listed - is that 2 input documents, or one field value?
- nickhumble2 years agoNew Contributor II
It's 2 input documents, thanks.
- nickhumble2 years agoNew Contributor II
koryknick any ideas? Thanks!
Related Content
- 4 months ago
- 2 years ago
- 3 years ago
- 3 years ago