Hi Everyone,
I have a set of product array data in a CSV file, as shown in the example below.
| SKU | Quantity | categoryID | categoryName |
| ABC|DER | 1|4 | Category123;Category122;Category333|Category111;Category888 | Watch;Men;Apparel|Shirt;Women |
Now, I want to map these field to ProductListItems array field in Adobe Analytics Experience Event Template. I am able to Map the SKU, and Quantity field using array_to_objects and explode functions. When I use this same functions for the categoryID, and CategoryName I am getting the below output,
Formula:
arrays_to_objects('SKU',explode(SKU,'\|'),'Quantity',explode(Quantity,'\|'), 'ProductCategories.CategoryName',explode(categoryName,'\|'),'ProductCategories.CategoryID',explode(categoryID,'\|'))
Output:
[{"Quantity":"1","SKU":"ABC","ProductCategories.CategoryName":"Watch;Men;Apparel","ProductCategories.CategoryID":"Category123;Category122;Category333"}]
Not able to use the array_to_objects function within the array_to_objects function.
The output I actually need is given below,
[{
"Quantity":"1",
"SKU":"ABC",
"ProductCategories":[
{
"CategoryName":"Watch",
"CategoryID":"Category123"
},
{
"CategoryName":"Men",
"CategoryID":"Category122"
},
{
"CategoryName":"Apparel",
"CategoryID":"Category333"
}
]
}]
What is the recommended method for accomplishing this with a calculated field? I’d appreciate any best practices.
Thanks in advance.!