Questions tagged [dataweave]

The DataWeave Language is a powerful template engine that allows you to transform data to and from any kind of format (XML, CSV, JSON, Pojos, Maps, etc).

DataWeave is the MuleSoft expression language for accessing and transforming data that travels through a Mule app. DataWeave is tightly integrated with the Mule runtime engine, which runs the scripts and expressions in your Mule app.

DataWeave scripts act on data in the Mule event. Most commonly, you use it to access and transform data in the message payload. For example, after a component in your app retrieves data from one system, you can use DataWeave to modify and output selected fields in that data to a new data format, then use another component in your app to pass on that data to another system.

Full Reference

https://docs.mulesoft.com/mule-user-guide/v/3.7/dataweave-reference-documentation

https://docs.mulesoft.com/mule-runtime/4.2/dataweave

1845 questions
3
votes
1 answer

How to convert ManagedCursorStreamProvider to JSOn object in mule 4

How to convert ManagedCursorStreamProvider to Json object in mule. I have written a java method which takes the Json Object as input Request Payload: { a: "one", b : "two"} Invoke static arg0 : payload Java Function called using invoke…
HMT
  • 2,093
  • 1
  • 19
  • 51
3
votes
1 answer

Mule changing the date format

I am trying to convert date from "dd-MM-yyyy" format to "dd/MM/yyyy" dob as Date {format: \"dd-MM-yyyy\"} as String {format :\"dd\/MM\/yyyy\"} I am getting a dataweave parsing error. Please help
HMT
  • 2,093
  • 1
  • 19
  • 51
3
votes
2 answers

Dataweave 2.2 What's the difference between takeWhile and filter?

%dw 2.0 import * from dw::core::Arrays output application/json var arr = [0,1,2,4,3] --- arr filter $ <= 2 and %dw 2.0 import * from dw::core::Arrays output application/json var arr = [0,1,2,4,3] --- arr takeWhile $ <= 2 They both give the same…
Dale
  • 1,289
  • 3
  • 16
  • 36
3
votes
1 answer

How to navigate a mutipart/form-data in Mulesoft 4.2 Dataweave 2.2?

I'm trying to get grab content out of multipart/form-data in Dataweave 2.2. I just want to send back the pdf from the second part of the payload. I am having no luck parsing through this payload using Dataweave. My dataweave code is simply…
Dale
  • 1,289
  • 3
  • 16
  • 36
3
votes
3 answers

Parallel For-Each vs Scatter Gather in mule

I have multiple records : { "item_id":1", key1: "data1" } { item_id:2 key1: "data1" } { item_id:2 key1: "data1" } { item_id:1 key1: "data1" } I do not want to process them sequentially.There can be more than 200 records. Should I process…
HMT
  • 2,093
  • 1
  • 19
  • 51
3
votes
1 answer

Preview transformation in vscode using javascript/typescript

We are consuming apis returning json in our projects. The json from those api can contain rather large structures which need to be mapped into other large structures (usually json but could be xml or csv rarely). We used to use dataweave (from…
Gerben Rampaart
  • 9,853
  • 3
  • 26
  • 32
3
votes
1 answer

Lookup Country Code from the phone Numbers using Dataweave Mule

My Input Request JSON looks like this below: { "phoneNumbers": [{ "phoneNumberType": "mobile", "phoneNumber": "54112724555" }, { "phoneNumberType": "mobile", "phoneNumber": "16298765432" } ] } I…
Infinity
  • 484
  • 2
  • 8
  • 21
3
votes
1 answer

How do I sort descending in dataweave?

This works for ascending. vars.results orderBy (results) -> results.name but can't figure out how to sort descending by name
3
votes
3 answers

Unable to call `++` with (`String`, `Array`)

I'm trying to format a phone number like phoneNumber: "+1" ++ payload.phoneNumber and I'm getting an error cannot coerce an Array to String. Why does my output think I have an Array and not just a String? The error message I'm getting is...…
3
votes
1 answer

DataWeave 2.0 Backslash escaping

How can you get a single backslash in DataWeave 2.0? %dw 2.0 output application/json --- { "attempt1": "\String", "attempt2": "\\String" } Returns: { "attempt1": "\\String", "attempt2": "\\String" }
jerney
  • 2,187
  • 1
  • 19
  • 31
3
votes
2 answers

Dataweave - Replace value of a field in an object

I have a Java Object as input payload: { "name"="Michael", "surname"="Alpha", "mail"="demo@gmail.com", "gender"="Male" } I want change the gender value keeping the rest of the message: %dw 2.0 output application/java --- gender: if(payload.gender…
gtx911
  • 1,189
  • 4
  • 25
  • 46
3
votes
1 answer

xml elements with same attribute names getting overriden

My XML Structure looks like below:- Roll jayz eminem drake After transformation I am…
leo_roar_001
  • 181
  • 1
  • 10
3
votes
1 answer

Mulesoft: Remove duplicate records by checking dateField using dataweave

I have a csv file with following…
Prudhvi B
  • 144
  • 2
  • 13
3
votes
2 answers

Mule (Dataweave) transform JSON array to string

This is probably simple, but everything I find in a search is only vaguely related to my question. I have this: { "user":"C03999", "caseNumber":"011-1234567", "documents":[ { "file":[ …
Keith Fosberg
  • 89
  • 2
  • 9
3
votes
5 answers

Split string in dataweave

I have a string like "Hi I am from "Kazan, Russia". The output should be Hi I am from Kazan, Russia I tried the regex [^\s\"']+|\"([^\"]*)\"|'([^']*)', which works fine on regexp.com. But in dataweave it does nothing. This is what I tried %dw…
Abhay
  • 314
  • 1
  • 2
  • 11