โ12-23-2018 09:27 AM
We have a complex JSON object which has the columns information in one array and the row values in another. We would like the output to simply have the merged structure with value of the โTitleโ attribute held in the โmyColsโ as the key and the value from the โmyRows.Cells.valueโ mapped.
We would like a row for each myRows element. Weโd like to do this without using the absolute index numbers of either and leverage the โmyCols.idโ and โmyRows.cells.columnIdโ which are how they align. The purpose of this is to have a dynamic source and which can have any number of columns that could eventually create a results table and insert the rows.
Any ideas?
[
{
โmyColsโ: [
{
โidโ: 7169064356341636,
โversionโ: 0,
โindexโ: 0,
โtitleโ: โORG_VALUE_SRCโ,
โtypeโ: โTEXT_NUMBERโ,
โprimaryโ: true,
โvalidationโ: false,
โwidthโ: 150
},
{
โidโ: 1539564822128516,
โversionโ: 0,
โindexโ: 1,
โtitleโ: โORG_VALUE_TGTโ,
โtypeโ: โTEXT_NUMBERโ,
โvalidationโ: false,
โwidthโ: 150
},
{
โidโ: 6043164449499012,
โversionโ: 0,
โindexโ: 2,
โtitleโ: โCREATE_DATEโ,
โtypeโ: โTEXT_NUMBERโ,
โvalidationโ: false,
โwidthโ: 150
},
{
โidโ: 3791364635813764,
โversionโ: 0,
โindexโ: 3,
โtitleโ: โUPDATE_DATEโ,
โtypeโ: โDATEโ,
โvalidationโ: false,
โwidthโ: 150
}
],
โmyRowsโ: [
{
โidโ: 7737866304415620,
โrowNumberโ: 1,
โexpandedโ: true,
โcreatedAtโ: โ2018-12-18T17:48:08Zโ,
โmodifiedAtโ: โ2018-12-18T17:48:08Zโ,
โcellsโ: [
{
โcolumnIdโ: 7169064356341636,
โvalueโ: 1400076,
โdisplayValueโ: โ1400076โ
},
{
โcolumnIdโ: 1539564822128516,
โvalueโ: โ1400076GBPโ,
โdisplayValueโ: โ1400076GBPโ
},
{
โcolumnIdโ: 6043164449499012
},
{
โcolumnIdโ: 3791364635813764,
โvalueโ: โ2018-02-28โ
}
]
},
{
โidโ: 2108366770202500,
โrowNumberโ: 2,
โsiblingIdโ: 7737866304415620,
โexpandedโ: true,
โcreatedAtโ: โ2018-12-18T17:48:08Zโ,
โmodifiedAtโ: โ2018-12-18T17:48:08Zโ,
โcellsโ: [
{
โcolumnIdโ: 7169064356341636,
โvalueโ: 1400076,
โdisplayValueโ: โ1400076โ
},
{
โcolumnIdโ: 1539564822128516,
โvalueโ: โ1400076EURโ,
โdisplayValueโ: โ1400076EURโ
},
{
โcolumnIdโ: 6043164449499012
},
{
โcolumnIdโ: 3791364635813764,
โvalueโ: โ2018-02-28โ
}
]
},
{
โidโ: 6611966397572996,
โrowNumberโ: 3,
โsiblingIdโ: 2108366770202500,
โexpandedโ: true,
โcreatedAtโ: โ2018-12-18T17:48:08Zโ,
โmodifiedAtโ: โ2018-12-18T17:48:08Zโ,
โcellsโ: [
{
โcolumnIdโ: 7169064356341636,
โvalueโ: 1400077,
โdisplayValueโ: โ1400077โ
},
{
โcolumnIdโ: 1539564822128516,
โvalueโ: โ1400077GBPโ,
โdisplayValueโ: โ1400077GBPโ
},
{
โcolumnIdโ: 6043164449499012
},
{
โcolumnIdโ: 3791364635813764,
โvalueโ: โ2018-02-28โ
}
]
}
]
}
]
โ12-23-2018 08:47 PM
โ12-24-2018 05:18 AM
Sorry should have provided the structure too
More like this:
[
[
{
โnewRowsโ: [
{
โrowNumberโ: 1,
โORG_VALUE_SRCโ: โ1400076โ,
โORG_VALUE_TGTโ: โ1400076GBPโ,
โCREATE_DATEโ: โ2018-02-28โ,
โUPDATE_DATEโ: โ2018-02-28โ
},
{
โrowNumberโ: 2,
โORG_VALUE_SRCโ: โ1400076โ,
โORG_VALUE_TGTโ: โ1400076EURโ,
โCREATE_DATEโ: โ2018-02-28โ,
โUPDATE_DATEโ: โ2018-02-28โ
},
{
โrowNumberโ: 3,
โORG_VALUE_SRCโ: โ1400077โ,
โORG_VALUE_TGTโ: โ1400077GBPโ,
โCREATE_DATEโ: โ2018-02-28โ,
โUPDATE_DATEโ: โ2018-02-28โ
}
]
}
]
]
Basically a row for every source row using the โTitleโ as the key and โValueโ from โmyRows.cellsโ as the value. My need is grander than this but figured if someone could steer me in the right direction we could take it from there.
Thanks
โ12-26-2018 12:51 AM
Hi Brian,
I tried to achieve your requirement by using script snap.
readComplexJson_2018_12_26.slp (12.3 KB)
โ12-26-2018 04:57 AM
Thank you that helped and also validated that it needed to be a script block. Wanโt sure if there was any magic jsonPath or other Snap that could do this without scripting. Do you know if there are any limitations on using script blocks is large data streams? Just trying to understand best practices when using Script Blocks.