Forum Discussion

Sahil's avatar
Sahil
Contributor
4 years ago
Solved

Join 2 arrays

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)

15 Replies

    • Sahil's avatar
      Sahil
      Contributor

      Hi,Thank you for the pipeline.

      There are 2 issues in the pipeline:-

      1. If we use
        jsonPath($, “$ContentObjectProperty[*][‘$’]”).filter(x=>x!='feature ')
        it picks all the content even from shortText and longText. We need to pick only Name.
        2)I see an error at JSON Splitter3
        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's avatar
        bojanvelevski
        Valued Contributor

        I used the file you sent, so if you’re using a different file, try to adjust the pipeline to work with that one, or send the file so I can try and do the modifications

  • bojanvelevski's avatar
    bojanvelevski
    Valued Contributor

    Can you provide a sample of how the object looks? If you’re having both arrays in one object than you can use copy, in the upper branch split the first array, and in the lower one, split the other. Than you can join both streams with a Join snap.

    Input:

    Setup:

    Output:

    • Sahil's avatar
      Sahil
      Contributor

      Thank you, could you please tell me what should be the json path for splitting the array?

  • bojanvelevski's avatar
    bojanvelevski
    Valued Contributor

    In the sample I provided, the json paths are the names of the arrays, $array1/array2 accordingly.

    • Sahil's avatar
      Sahil
      Contributor

      Hi
      Sample xml File is uploaded in the original question.
      I need to create output csv file having output as:-
      Uber John
      Uber Michael
      Ola Shane
      Ola Wick

  • bojanvelevski's avatar
    bojanvelevski
    Valued Contributor

    I checked your sample, but it’s not as nearly flat as you described it. I’ll need some time to do further analysis