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
2
votes
1 answer

How to group a JSON dataset by two properties and sum the value in dataweave?

I have a data set which I am trying to group by two separate keys, but nested. I have tried to use the groupBy method but I am then having a hard time with the sum within the keys. I have also tries to use the pluck method but that also seems to…
anonMule
  • 91
  • 2
2
votes
1 answer

How to remove the DTOSteps node which contains id using mule 4

I am trying to remove DTOSteps node if it contains an ID attribute. Input XML:
codey_08
  • 249
  • 1
  • 11
2
votes
1 answer

Convert TEXT file to JSON in Dataweave

How can I convert TEXT file into JSON in Dataweave. Input: "[ { "quantity": "1.0", "uom": "every", "amount": "5.0", "allocation": [ { "ID": "22245", "price": "156", "desc": "Product A1" } ], …
Vikash
  • 21
  • 2
2
votes
1 answer

if else statement Mule 3

I want to set a variable based on the output in Mule 3. For example the check I want to do is if there is any payload I want to set the var value to this ${http.path.one} else ${http.path.two}. In Mule 4 it can be done in multiple ways but in Mule 3…
Makavelines
  • 111
  • 6
2
votes
1 answer

Anypoint Studio problem with JSON into XML transformation

I am trying to convert JSON response into XML and then call SOAP API with payload. I managed to get JSON response without any trouble, but I am unable to convert it to XML. the problem is data has to be in format:
Curiosity
  • 81
  • 6
2
votes
1 answer

Database Columns values mismatch when creating csv pipe seperated file from database records

Mule 4 App has been doing select from a SQL Server database around 20k rows and convert result set into pipe separated csv file and push the file to s3 using s3 connector. In the database, we have columns like aId, bId, cId etc. When we checked the…
Infinity
  • 484
  • 2
  • 8
  • 21
2
votes
2 answers

How to combine a JSON object inside another nested JSON object using Dataweave 2.0

I have two input payloads and I want to combine a JSON object inside another nested JSON object to a specific object. The expected output is to combine Input 2 with Input 1 under "Response_Data". I tried but I could combine Input 2 at the end but…
user12277274
  • 105
  • 2
  • 15
2
votes
3 answers

How to access a multi value XML containing a json string

I have a json string inside a multi value xml tag, which I'm struggling to access. I would like to concatenate the "pid" values to have something like "listOfPids" : "0000444, 0000111"
maco
  • 55
  • 7
2
votes
2 answers

Change timezone from undefined to utc in dataweave

I have a plain date / time string (local european summer / winter time) I would like to transform into UTC. The date I receive looks like this {"message": "2021-05-01 15:39"} But using LocalDateTime like this (payload.message as LocalDateTime …
maco
  • 55
  • 7
2
votes
1 answer

How to give Relative Path in Mule File Read?

Hi I created a folder and placed a sample XML file in src/main/resources/samplexml/samplxml.xml. File Config i did as In File…
VKP
  • 589
  • 1
  • 8
  • 34
2
votes
1 answer

JSON array to Table structure formatting while sending email via Mule 4

I have a requirement to send the error report as a tabular format, which needs to be sent as a email body. I am constructing error report as a JSON array and I would need to do the HTML transformation to structure that as table format. Below is the…
Deeps
  • 47
  • 9
2
votes
3 answers

Dataweave 2 How to map Object to JSON Arrays of Object

Have a JSON Object which I need to map to an array of objects but can't get the structure right after many tries. Would it be better, if the script gets very complex and damages readability and ease of maintenance, to have this process divided into…
Tomeister
  • 675
  • 2
  • 9
  • 26
2
votes
3 answers

how to check if any one element of a variable length String array is present in another variable length string array

inputArray = ["cat", "bat", "mat"] configuredArray = ["dog", "elephant", "fox", "cat"] inputArray and configuredArray are variable length String arrays. If any one element of the inputArray is present in the configuredArray I would like to set a…
jpass abba
  • 21
  • 2
2
votes
4 answers

MuleSoft Dataweave reduce

I try to get my head around the reduce function in Mulesoft Dataweave 2.0. expected outcome: { "dev": "1", "test": "2", "uat": "3", "prod": "4" } my dataweave code: %dw 2.0 var invar = [ {"id": "1", "name": "dev"}, {"id": "2", "name":…
Ben
  • 594
  • 1
  • 9
  • 24
2
votes
1 answer

How to remove XML namespace in Mulesoft Dataweave

When I transform a message with Mulesoft dataweave I want to get rid of all the xmlns namespaces. This is my message:
Ben
  • 594
  • 1
  • 9
  • 24