Hi @Shay Levy , Welcome to Microsoft Q&A forum and thanks for reaching out here.
You can use a derived column and aggregate transformation to achieve your requirement in mapping data flow.
Here is a video demonstration on how to create a complex JSON structure from Hierarchical source using Mapping data flows in ADF: Load CSV file in to JSON with Nested Hierarchy using Azure data factory
Here is the public documentation on how to create the JSON structure using derived column in mapping data flow: Creating JSON structures in a derived column transformation of ADF mapping data flow Here is a sample script which is create a complex structure as per your requirement. You will need to enhance it accordingly based on your source structure. (Please note this is just a sample for your reference, please make changes as needed)
source derive(type = type,
action = action,
identifiers = @(email=email),
data = @(ts=@(order=@(order_ID=order_id,
total=total,
OrderDiscount=OrderDiscount,
OrderSubtotal=OrderSubtotal,
tax=tax,
shipping=shipping,
coupon_code=coupon_code,
order_type=order_type,
items=@(product_id=product_id,
item_sku=item_sku,
item_price=item_price,
item_quantity=item_quantity,
item_discount=item_discount,
Item_subtotal=Item_subtotal))))) ~> derivedColumn2
derivedColumn2 aggregate(groupBy(order_id,
total,
OrderDiscount,
OrderSubtotal,
tax,
shipping,
coupon_code,
order_type),
items = collect(data.ts.order.items)) ~> aggregate1
Hope this helps.
Please don’t forget to Accept Answer
and Yes
for "was this answer helpful" wherever the information provided helps you, this can be beneficial to other community members.