Skip to content

Instantly share code, notes, and snippets.

@shaneberry
Created March 27, 2024 15:35
Show Gist options
  • Save shaneberry/416eba1d539a2a223d2ec1dafcd6b2ae to your computer and use it in GitHub Desktop.
Save shaneberry/416eba1d539a2a223d2ec1dafcd6b2ae to your computer and use it in GitHub Desktop.
Dataweave Example using map, flatMap, distinctBy & orderBy
%dw 2.0
output application/json
---
payload
map ((item, index) -> item.ErrorDetail.ValidationMessages) // Extract ValidationMessages from each item
flatMap ($) // Flatten the array of arrays into a single array
distinctBy ($.Message) // Remove duplicate messages based on the Message field
orderBy ($.Message default "")
map ($.Message) // Extract just the Message field
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment