Dataweave accepts Apex List as JSON and fieldName as string, returns Apex Map as JSON

PHOTO EMBED

Fri Jul 19 2024 21:49:40 GMT+0000 (Coordinated Universal Time)

Saved by @taurenhunter

%dw 2.0
input records application/json
input fieldName text
output application/json
---
{(records map (record) -> 
    ( record[ fieldName ] ) : record 
)}
content_copyCOPY