02-20-2019 05:46 AM
Hi Team,
Is there is simple way to take an input JSON record and produce the output that is shown below?
This is a simplified version of what is trying to be achieved…
The input record contains two variables and an array of “skus” consisting of items with two variables, a “skucode” and a “shade”.
Each output record is a superset of the input record. Each output record promotes one of the array items above the array to the same level as the two variables in the input record, as shown in the example below.
Input:
{
“code”: “ABCD”,
“name”: “Product A”,
“sku”: [
{
“skucode”: “ABCD12”,
“shade”: “green”
},
{
“skucode”: “ABCD13”,
“shade”: “brown”
},
{
“skucode”: “ABCD14”,
“shade”: “blue”
},
{
“skucode”: “ABCD15”,
“shade”: “red”
},
]
}
Output:
[{
“code”: “ABCD”,
“name”: “Product A”,
“skucode”: “ABCD12”,
“shade”: “green”
“sku”: [
{
“skucode”: “ABCD12”,
“shade”: “green”
},
{
“skucode”: “ABCD13”,
“shade”: “brown”
},
{
“skucode”: “ABCD14”,
“shade”: “blue”
},
{
“skucode”: “ABCD15”,
“shade”: “red”
},
]
},
{
“code”: “ABCD”,
“name”: “Product A”,
“skucode”: “ABCD13”,
“shade”: “brown”
“sku”: [
{
“skucode”: “ABCD12”,
“shade”: “green”
},
{
“skucode”: “ABCD13”,
“shade”: “brown”
},
{
“skucode”: “ABCD14”,
“shade”: “blue”
},
{
“skucode”: “ABCD15”,
“shade”: “red”
},
]
},
{
“code”: “ABCD”,
“name”: “Product A”,
“skucode”: “ABCD14”,
“shade”: “blue”
“sku”: [
{
“skucode”: “ABCD12”,
“shade”: “green”
},
{
“skucode”: “ABCD13”,
“shade”: “brown”
},
{
“skucode”: “ABCD14”,
“shade”: “blue”
},
{
“skucode”: “ABCD15”,
“shade”: “red”
}
]
},
{
“code”: “ABCD”,
“name”: “Product A”,
“skucode”: “ABCD15”,
“shade”: “red”
“sku”: [
{
“skucode”: “ABCD12”,
“shade”: “green”
},
{
“skucode”: “ABCD13”,
“shade”: “brown”
},
{
“skucode”: “ABCD14”,
“shade”: “blue”
},
{
“skucode”: “ABCD15”,
“shade”: “red”
}
]
}
]
02-20-2019 09:05 AM
You can do this with the JsonSplitter snap. Here’s a pipeline that demos the example you wrote up.
SkuSplitter_2019_02_20.slp (3.8 KB)
02-21-2019 01:15 AM
Excellent, that’s actually what we needed. Thank you