AEP Datastream Data Mapping/Data Prep: Help needed to transform objects in an array using calculated fields for analytics list variables
I'm trying to use Calculated Fields in Data Mapping to transform objects in an input array that look like [{"key1":"string1","key2:"string2"},{"key1":"string1","key2:"string2"}] to an output array of objects that look like [{"value":"string1=string2"},{"value":"string1=string2"}], but I can't figure out the format needed for the input Source Fields, the combination of calculated fields needed, or the format needed for the output Target Field.
The objects in the array are always a pair of key:string, but the array is a dynamic size, sometimes containing dozens of {"key1":"string1","key2:"string2"} objects, so it's not feasible to individually reference the fields in each object in the input array entry via [0], [1], [2], etc. I tried using data.page.facetRefinement[*].name but the Calculated Field tool won't accept it.
Example input JSON:
{
"data": {
"page": {
"facetRefinement": [
{
"name": "Document Type",
"value": "PDF"
},
{
"name": "Category",
"value": "Important Stuff"
}
]
},
"eventInfo": {
"component": [
{
"type": "Image",
"name": "Hero"
}, {
"type": "List",
"name": "What's new!"
}, {
"type": "Carousel",
"name": "Featured Things"
}
]
}
}
}
Desired output (note: desired output format corrected based on @kautuk_sahni's reply):
{
"_experience": {
"analytics": {
"customDimensions": {
"lists": {
"list1": [
{"value": "Document Type=PDF"},
{"value": "Category=Important Stuff"}
],
"list2": [
{"value": "Image=Hero"},
{"value": "List=What's new!"},
{"value": "Carousel=Featured Things"}
]
}
}
}
}
}
Anyone have any ideas?
Thanks!
-Phil