JSON Ungroup lower level list while keeping upper level elements

I am trying to ungroup a JSON file with an embedded list and I want each “row” of the result to contain all the other elements of the JSON. I am able to extract and group the lower level list on its own but don’t know how to get the rest re-attached.

Input:
{
“column1” : “value1”,
“column2” : “value2”,
“embedded_list” :
[
“listvalue1”,
“listvalue2”
]
}

Desired output:
Row1
{
“column1” : “value1”,
“column2” : “value2”,
“embedded_list” : “listvalue1”
}

Row2
{
“column1” : “value1”,
“column2” : “value2”,
“embedded_list” : “listvalue2”
}

Ultimately this is going to a table format, so if that can be accomplished without this intermediate JSON format, that’s good too. Right now I am losing column1 and column2 with my ungroup function.

Perhaps not exactly what you wanted, but could give you inspiration.

embedded.knwf (62.5 KB)

1 Like

You are right on both counts. It may not work in the much more complex environment of my application, but it does provide inspiration because I can see how many of these functions work. This is basically a text manipulation solution, where I need a more generic JSON based solution that multiplies rows for an embedded list with multiple entries.

A co-worker came up with something that might work, and I will put it here if I can confirm it.

Thanks for the quick response!

If you use the JSON Path node, you can extract column 1 and 2 from the JSON into a table. At the same time you can extract the list with the add collection query option. This will add the list as list item, which you can then ungroup. The columns 1 and 2 will stay attached this way.
JSON ungroup.knwf (9.2 KB)

Is this what you were looking for?

4 Likes

That’s it right there! Thanks.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.