cancel
Showing results for 
Search instead for 
Did you mean: 

Join 2 arrays

Sahil
Contributor

I have 2 different arrays, one having id, header and another having id,name.
Need to join these 2 arrays and get an output file of id,header,name.
I need json splitter json path, I have just for id which is jsonPath($, “id[*]”).
How do I include both id and header.
File.txt (4.2 KB)

1 ACCEPTED SOLUTION

bojanvelevski
Valued Contributor

try different mapping, change the ‘$’ to something else

View solution in original post

15 REPLIES 15

Hi @bojanvelevski , have a look at it please.

bojanvelevski
Valued Contributor

Join 2 arrays_2022_04_20.slp (20.9 KB)

The following updates were made:

• Filter is added after splitting the products. There are products without any “ObjectGroups” path that need to be filtered.
• Expression for getting the “Name” is changed in Mapper2 to more accurate one that gets exactly the field we need.

Hi, Could you please try to run this file,
file2.txt (4.9 KB)
seeing:
Failure: Json Splitter expects a list, Reason: Found an object of type class java.util.LinkedHashMap, Resolution: The path $.ObjectRef needs to refer to a list in the incoming document

bojanvelevski
Valued Contributor

In lower branch Mapper3, change the expression to:

sl.ensureArray($OtherData.ObjectGroups.ObjectGroup.ObjectRef)

This happens because in one document, there’s only one object, so you need to make sure that you add that one in an array.

Hi, Thanks it solved the problem. Although when i am trying to use CSV Formatter after join getting error:-
Failure: Index -1 out of bounds for length 0, Reason: Snap failed unexpectedly and did not provide any reason
I am mapping like below:-
$Name
$[‘$’]