Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]
Created 05-26-2023 12:13 AM
Hi Community,
hope someone can help me to build this transform:
My Input:
{
"Orders": [{
"Headers": {
"UniqShipment": "0"
},
"Goods": [{
"GoodsTypeID": 3,
"GoodsTypeName": "ALTRI MOBILI LEGNO",
"GoodsDetails": [{
"Packs": 1
}, {
"Packs": 1
}, {
"Packs": 1
}]
}],
"References": [{
"TypeReference": "DT",
"ValueReference": "006611",
"DateReference": "2023-04-14"
}, {
"TypeReference": "CM",
"ValueReference": "JOHN"
}, {
"TypeReference": "OC",
"ValueReference": "V1250-0010"
}, {
"TypeReference": "RG",
"ValueReference": "TRCA_CATR726240_CA_006611_14_04_2023.json"
}]
}]
}My Desired Output:
{
"header": {
"UniqShipment": "0"
},
"rows": {
"GoodsTypeName": ["ALTRI MOBILI LEGNO", "ALTRI MOBILI LEGNO", "ALTRI MOBILI LEGNO"],
"Packs": [1, 1, 1],
"ValueReference": ["V1250-0010", "V1250-0010", "V1250-0010"]
}
}My Transformation so far:
[
{
"operation": "shift",
"spec": {
"Orders": {
"*": {
"Headers": "header",
"Goods": {
"*": {
"GoodsDetails": {
"*": {
"@(2,GoodsTypeName)": "rows.GoodsTypeName",
"Packs": "rows.Packs"
}
}
}
}
}
}
}
}
]Which Produce the following result:
{
"header" : {
"UniqShipment" : "0"
},
"rows" : {
"GoodsTypeName" : [ "ALTRI MOBILI LEGNO", "ALTRI MOBILI LEGNO", "ALTRI MOBILI LEGNO" ],
"Packs" : [ 1, 1, 1 ]
}Now i need to make the last part:
Based on the value of TypeReference which has to be "OC" then add the list of ValueReference per each element of "rows array" like this:
{
"header": {
"UniqShipment": "0"
},
"rows": {
"GoodsTypeName": ["ALTRI MOBILI LEGNO", "ALTRI MOBILI LEGNO", "ALTRI MOBILI LEGNO"],
"Packs": [1, 1, 1],
"TypeReference": ["V1250-0010", "V1250-0010", "V1250-0010"]
}
}
Many Thanks for your help, appreciate!
Created on 05-26-2023 07:17 AM - edited 05-26-2023 07:17 AM
Hi,
I think you can achieve this in two shift transformation as follows:
[
{
// 1st transformation is basically to isolate
// "OC" value reference into Orders.ValueReference
"operation": "shift",
"spec": {
"Orders": {
"*": {
"Headers": "Orders[#2].&",
"Goods": "Orders[#2].&",
"References": {
"*": {
"TypeReference": {
"OC": {
"@(2,ValueReference)": "Orders[#2].ValueReference"
}
}
}
}
}
}
}
},
//2ed Transformation is the same as you had except for
//fetching the isolated ValueReference above
//into its own Array based on the GoodsDetails array
{
"operation": "shift",
"spec": {
"Orders": {
"*": {
"Headers": "header",
"Goods": {
"*": {
"GoodsDetails": {
"*": {
"@(2,GoodsTypeName)": "rows.GoodsTypeName",
"Packs": "rows.Packs",
"@(4,ValueReference)": "rows.ValueReference"
}
}
}
}
}
}
}
}
]
If the helps please accept solution.
Thanks
Created on 05-26-2023 07:17 AM - edited 05-26-2023 07:17 AM
Hi,
I think you can achieve this in two shift transformation as follows:
[
{
// 1st transformation is basically to isolate
// "OC" value reference into Orders.ValueReference
"operation": "shift",
"spec": {
"Orders": {
"*": {
"Headers": "Orders[#2].&",
"Goods": "Orders[#2].&",
"References": {
"*": {
"TypeReference": {
"OC": {
"@(2,ValueReference)": "Orders[#2].ValueReference"
}
}
}
}
}
}
}
},
//2ed Transformation is the same as you had except for
//fetching the isolated ValueReference above
//into its own Array based on the GoodsDetails array
{
"operation": "shift",
"spec": {
"Orders": {
"*": {
"Headers": "header",
"Goods": {
"*": {
"GoodsDetails": {
"*": {
"@(2,GoodsTypeName)": "rows.GoodsTypeName",
"Packs": "rows.Packs",
"@(4,ValueReference)": "rows.ValueReference"
}
}
}
}
}
}
}
}
]
If the helps please accept solution.
Thanks