Forum Discussion

maahutch's avatar
maahutch
New Contributor
2 years ago
Solved

Reshape document to denormalized table

I have a document like this: 

[
  {
    "first": ["1", "2"],
    "second": "a"
   },
  {
    "first": ["3", "4"],
    "second": "b"
  } 
]

 And I'm trying to convert it to a table like this: 

FirstSecond
1a
2a
3b
4b

I'm thinking I need to use the "map" or "mapValue" function but I can't figure out how to do it. Any ideas? 

  • Hi maahutch ,

    You can use the JSON Splitter snap. You will need to split the $first and add the $second as an included path.
    Include paths allow you to include objects from the input document in the resulting output document.



    After JSON Splitter you will need to rename the column name because, by default, the snap will return splitValue.

    Hope this helps!
    BR.
    Ivica

     



1 Reply

  • ivicakoteski's avatar
    ivicakoteski
    New Contributor III

    Hi maahutch ,

    You can use the JSON Splitter snap. You will need to split the $first and add the $second as an included path.
    Include paths allow you to include objects from the input document in the resulting output document.



    After JSON Splitter you will need to rename the column name because, by default, the snap will return splitValue.

    Hope this helps!
    BR.
    Ivica