Dataweave Mapobject
Dataweave MapobjectA code snippet with syntax would really helpful.
Dataweave into a single Array">Map multiple string Arrays using Dataweave into a single Array.
Here are two type of definition, T and R. Accessing variable inside of forEach in mule. In the case of the DataWeave script below, we will return the header information in the body of the response. I am using `map` for transformation but can't figure out how to avoid ` [ {}]` and have ` {}`. A status in XML needs to change before it gets forwarded. ! [alt text] [1] How can I iterate the json elements in dataweave. The anonymous function(value, index) → {index: value}maps each item in the input to an object. default -> fn ($) } %function trimWhitespace (v) trim v when v is :string otherwise v. combinedFees` is an array of, let's say wire transfers and each wire transfer …. This is a compilation of all the core functions that can be used in DataWeave Note: similar to mapObject - mapObject returns an object and . (storeName: "SSIB2BStore") when Order. 0 %input payload application/json %output application/xml --- { root: { (payload map { node1: $.
Append data to Array object in dataweave 2.
However, map is accessed by a key, such as map. You will also learn how to use pluck in combination with groupBy to achieve a common use case.
to remove objects that have all keys with null ">mule.
Dataweave Question: mapObject or Map.
0 % output application / json % var vlist = ["key1", "key4", "key3"]---payload map ($ mapObject {($$): "XXX" when (vlist contains ($$ as: string)) otherwise $}) Please check below code, % dw 1. The remaining values in the Team Name and Role keys for those objects. When implementing integration flows using Mule ESB. Use Date and Time Formatting Characters. DataWeave Reference dw::Core mapObject mapObject mapObject (@StreamCapable object: { (K)?: V }, mapper: (value: V, key: K, index: Number) -> …. 0; output application / json---payload. Streaming accesses each unit of the stream sequentially. For other DataWeave versions, you can use the version.
How to filter an array of JSON in Mule DataWeave.
It may be a bit non intuitive at first but I used reduce () to do the later. Transformation of Json array in Dataweave. The output is correct because subsequent additions of the new key/value just overwrite the previous one.
How do I group and map an array of objects?.
Actually we need to loop through the JSON array (payload. Hi, I'm new to dataweave and struggling to get some code working. assignee } The update operator can also handle upserting the key …. Employees mapObject((value1, key1, index1) -> Employee: value1 mapObject ((value2, key2, index2) -> (key2): index1) ) Output for the input in the description:. payment_addition_info) filter ($. 0 import * from modules::Namespaces output application/java var myNs1Local = myNs1 as Namespace --- { body: { myNs1Local#Response: { outcome: 'ACCEPTED' } } write "application/xml" }. id)) all of which would give you the same result. For other DataWeave versions, …. 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). MuleSoft dataweave expression language provides a rich set of functions and operators which can be used to perform various types of operations on payload to achieve desired transformations. When the output payload has a complicated structure, the performance is quite poor when comparing to the code I tried in Java class.
4 convert Binary payload into JSON.
It takes in an Object, and a lambda that takes in 3 parameters, a value, key, and index, and returns a new Object. Don’t have an account? Sign up. DW update function works only specific fields, how can I make for all the fields with update functions? %dw 2. The condition (or expression) used to match an element in the array.
DataWeave Delight: Splitting An Array Or Object.
Connect and share knowledge within a single location that is structured and easy to search. Input : I have variable value “1111121” and this will change every time with new request. Example of nested If else/when otherwise, is that we can split the conditions into individual ones. Yee Loon January 18, 2019 January 16, 2022 MuleSoft - Mapping 7 Comments. 0, whenotherwise has been replaced by ifelse. for better clarity of my question the JSON objects are below. 0 output application/json --- read (payload. Just like we have named functions, we have functions without names (or anonymous functions), called lambdas. For some neither reason skipOnNull="everywhere" nor skipOnNull="attribute" seem to be filtering empty attributes. 0 that made this work properly?. Here is the below Example from which we want to extract the First name and Last name and append both string by space. A lambda is a value in DataWeave, just like a String, an Object, or a Boolean. policyStatus, policyEffectiveDate: $. The example populates the title element with two attributes and each of the author elements with one attribute.
Usage of filterObject In Dataweave.
DataWeave fully supports XML namespaces. 0 Hi Folks, i want convert my JSON object to Json array and dynamic nested json object also there but it should be set into be JSON array. how update function work in DataWeave. I think there are two options to transform your InputString to a Map: A. This script should remove all keys mentioned in filterList that are 'empty'. mapObject takes two parameter an Object and a lambda. I have a scenario where am trying to remove the null and empty objects from the payload and found the below functions but I came to know that "using" is replaced by "do". This example iterates over an input array (["jose", "pedro", "mateo"]) toproduce an array of DataWeave objects. T represents the type of items that the input Array contains. When working with collections, use the map function to apply a transformation to each element in an array. x versions of DataWeave are used by Mule 4 apps. Map Object Elements as an Array.
What is DataWeave? Part 2: Selectors.
customAttributeList I wanted to add other object to customAttributeList array, I wanted rest of fields As-Is. Take an XML list of books and use DataWeave to output a JSON version of the book list. For information about how values for these types are defined, refer to Value Constructs for Types. This example iterates over an input array ( ["jose", "pedro", "mateo"]) to produce an array of DataWeave objects. 0 output application/json --- { "client_id": attributes. 0 %output application/json --- { result : payload mapObject ( (lower '$$') : $ ) }.
DataWeave using ">How to extract the keys from an Object in DataWeave using.
how to transfer object list to array and assign index number in the field name in dataweave. It is up to the integration specialist.
DataWeave map function: How to iterate through all items in.
Look Up Data in an Excel (XLSX) …. This example returns an array containing each value in order. It then uses map to iterate through the array this creates. 0 output application / json; payload mapObject ($): $$ Go through docs to get ideas and examples for dataweave : https. I tried distinct and filter, however filter. Here is one use case, where java static method takes Map as an argument, in Dataweave 2. You can group by id, extract the groups and map each one depending on the number of items per group. I am using map operator in Data weave. I can map the array to a single object if I filter by id but am unsure how to transform the data into an array of objects.
My top 5 DataWeave tips to make your life easier.
Use joinBy to get this into the string you'd like: %dw 1. Hi @kimmy - it should be doable and I have done something very similar in Dataweave 2. The filterObject operator iterates over a. Edited - added new dataweave logic - for taking number of fields to be changes % dw 1.
0— Introduction to Transformations.
0 % output application / json---payload map ($ mapObject. Try with this approach: In the resultant object as far Skus is concerned we take the iterating object and remove FirstName from it which leaves us with the Sku1, Sku2, Sku3.
If condition in a dataweave payload map.
It is primarily organized into sections by. DataWeave mapObject function: How to transform key/value pairs in an Object ; DataWeave pluck function: How to transform an Object into an Array ; If we just include one parameter, DataWeave will assume you’re referring to the value instead of the index.
0 core functions cheatsheet.
As second steps, we assume we receive an Array of products with the. Featured Solutions API Management Manage and secure any API, built and deployed anywhere Integration Connect any system, data, or API to integrate at scale Automation Automate processes and tasks for every team MuleSoft AI Connect data and automate workflows with AI Featured Integration Salesforce Power connected experiences with Salesforce integration SAP Unlock. A section is a key-value data structure, with a "title", a "reset_lesson_position" boolean, and a list of "lessons". Usage of Map and Map Object In DataweaveHaving said that, you can find an exten. myFunction is the name you define for the function. It has some syntactic sugar, like binary functions (with two arguments) can be written in infix notation. In a DataWeave script you can reference an application property defined in a properties files by using the p function of the dw::Mule module. ArrayList"} %input payload application/java %output application/csv --- { name: payload. For getting the first value: %dw 2. One of the major change in Mule 4 is, making DataWeave a default expression language over Mule 3’s default Mule Expression Language. Only in-place updates to applications are …. I'm talking about the mapObject . Mule Dataweave - converting array of array into. Learn how to use the following functions1. responses filterObject ( (value, key, index) -> value. Print the following Input to Output pattern. 4], } I tried splicing and splitting the array but I am not still arriving at the desired output. Ask Question Asked 2 years, 8 months ago. You can either click on the Tutorial button at the top-right of the screen, next to the Playground button; or click on the button …. When it comes to transforming between arrays and objects we have four different permutations: Array -> Array Object -> Object Object -> Array Array -> Object. DataWeave has been designed to transform data and does so in a performant way.
DataWeave – Transform Nested Structure to Flat using map and ….
What is difference between map and mapObject in Dataweave.
This update function updates the specified index of an array with the given PathElement value. In each cycle variable, $ holds the property’s value and $$ is the property’s name. How to do Partial Data Update in Mule. Apply useful Core, String, Array, Object, and Runtime module functions. Is there a way to map this based on key? 0. The result will be of the same type as the input Array. parts mapObject ( (value, key, index) -> (key): value. The skipNullOn = "everywhere" parameter is not necessary, as the null/empty check is already applied at the field level. descriptionValue} ) Otherwise you can use mapObject to iterate over the key-value pairs of each object and with. The DataWeave examples merge fields from separate input arrays. %var object = applyToValues (payload, trimWhitespace) ---. If you are coercing the value to a new type, use as. Below is the input and expected Output. Using the map Operator Follow along to see how to use the map operator. Splitting concatenated values in table column using Dataweave.
Cannot coerce a:array to an a:object in mule dataweave.
Getting started with DataWeave libraries in Anypoint Exchange.
We can use these functions to split an array into two arrays. You can choose whether functional and advertising cookies apply.
DataWeave: coding for MuleSoft • Stellaxius Knowledge Center.
DataWeave supports end-to-end streaming through a flow in a Mule application. In addition, DataWeave natively supports namespaces, CData an xsi:types. If a function with this annotation is not. This example updates the name of the user. As I'm fairly new to functional programming I put more focus on the Java implementation but ran into a number of issues. Remember an Object starts with { and end with } We. Input: { "employee":[ { "FirstName":"John". So based on key name you can use ++ to add field to child object. Reduce/combine the Array by adding `reduce ($$ ++ $)` between the main script and object expression. Higher-order functions are functions that take other functions as arguments, and/or return functions in response to a call. I have divided my dataweave script into modules, and I have used skipNullOn="everywhere" in the main dwl, so all the null values in all the modules are skipped. You dont need to apply map for your solution since descendant keys are same. If you were trying: payload map { , you'd get an object back out because of. 0 output application/json duplicateKeyAsArray=true --- payload. DataWeave Question: Convert HashMap to key=value String. 0 I did not see any example where Dataweave calling java method having Map object. Map operator goes through all the array elements on the left hand side and we can pick the values from on right hand side, Giving example from Mulesoft portal.
dataweave iterate array json to xml with map.
Used Map since items is an array hence there can be multiple entities inside items. Hundreds of companies of all sizes — from startups to Fortune 500s — partner with Apisero to automate, integrate, and transform their business using the ….
DataWeave Transformation (Map and MapObject Operator) With.
The object is the XML input to the read function. Convert json string into json object in mule. Follow edited Nov 25, 2015 at 1:27. Remove the additional bracket using flatten, because the map itself already returns an Array. 0 it is defined only for arrays and null. Step 2: Create Salesforce custom object – Mapping_Object__c. It also supports many data types, shown after the colon (:) in key-value pairs, such as myString: "hello world" and myNumber: 123. Handling Transformation of Arrays in DataWeave 2. Yes, you are right type is one of the reasons, but i tried changing the word and still it does not work in Dataweave 2. Convert Property File to YAML File. A new update operator added as part of Dataweave 2. I tried with mapObject which works only when the json doesn't have an array. The key difference between a list and a map is how they are accessed. how to map the attribute in the mapobject. All simple values are represented as strings.
Accessing values dynamically in data weave map operator.
We know that we can pass dynamic values directly using the syntax like below : Java. 0 output application/json --- payload filterObject ((value) -> value == true) Output: { "isAdult": true, "isIndian": true } Step 2. The returned keys belong to the Key type.
How to swap key and value from the payload in DataWeave 2.
0 output application/json fun treeFilter (value: Any, predicate: (value:Any) -> Boolean. , (if I have Id AB, AC, AC, AC, AB )= Tasks in output is 2 tasks(AB/AC) each for one unique id. 0 - conditionally change a single nested value. We will check a dataweave script to group all these values to their respective Id. Iterating Arrays Inside an Object.
Getting Started with the Apache Kafka Connector.
(The code that i mentioned in the question) The solution you provided works perfectly fine in 2. Would like to iterate over this array using map. 25 Why would you use SOAP instead of http? A. Using the previous example, you can test that if the input of the mapObject is null, the output result is null as well. An XML namespace is a W3C recommended mechanism that avoids name conflicts by differentiating XML elements or attributes that may have identical names, but different definitions. Just assume that variables are immutable in DataWeave. We use three kinds of cookies on our websites: required, functional, and advertising. Sign in for MuleSoft Training, self-paced and instructor-led courses. You just need to do the same thing …. DateAttribute_5ccef6de-d3c4-45a7-b538-c06dd55e4097_value})}**. Hi @tomminton, You are getting only one fees because of the way you are accessing `fees` collection. There are a number of other ways we might get the job done. The lambda passed to distinctBy should return a value that is unique to each item in the input Array. How to append fields in mule dataweave to existing json payload. The DataWeave example shows how to pass the XML attributes in the NameDetail field of the input source payload to the TargetName field of the XML output. I need to adhere to a JSON format but can't quite get my code to produce it exactly in the same way. 0 output application/json --- items: payload. But when it has array, it doesn't work. This ensures that the lower operator is applied to each of the keys first and then that value is used in the map. Using the DataWeave Playground. DataWeave mapObject function: How to transform key/value pairs in an Object ; DataWeave pluck function: How to transform an Object into an Array ; DataWeave reduce function: How to loop through and transform an Array into a different type ; How to extract the keys from an Object in DataWeave using keysOf, namesOf, or pluck. Dataweave dynamic mapping of key and value. The XML namespace of DataWeave is moved from dw to ee (core), and the DataWeave version has changed from 1. We’ll use the keysOf, namesOf, and pluck functions to demonstrate the differences between the type of Array that is returned from each function. You can refer Dataweave Selectors for further details. DataWeave; DataWeave Reference; dw::Core; joinBy. 0 // This Function takes a json and an array and spreads the json fields // across each elements of the array. It uses mapObject to iterate over the entire input object and return matching key-value. The Write operation returns a file, output.
DataWeave filterObject function: How to filter key/value pairs in an.
DataWeave Transformation (Map and MapObject Operator) With MuleSoft. The output groups fields by language and adds a new element, attendees, that contains the names of attendees for each course. I have this code that works in a Transform Message component: %dw 2. how to retrieve XML attributes dynamically inside dataweave funtion My requirement is to convert XML to json using DW but its not extracting the attributes from XML payload. If you enjoyed this blog you might be interested in the following posts about DataWeave functions. I know I have to wrap this in brackets {. Replacing Null with Blank blank in Dataweave 2. I am getting the keys, values dynamically in dataweave as. MuleSoftのウェブサイトに各モジュール毎の関数一覧や説明は記載されていますし、一度覚えてしまえば必要ないのかもしれ …. The selector returns the namespace URL, not the name. This will iterate over each key. %output application/xml skipNullOn = "everywhere". We use mapObject when we want to change the keys and/or values on an Object to be something else. Map function in Dataweave is used to iterate over array and output the result in to an array. For DataWeave in Mule 3 apps, refer to DataWeave.
how do I do a null check in dataweave.
Once we get a piece of data into DataWeave, we use selectors to navigate the data to get what’s needed. To simplify the development of your Dataweave scripts, you can access a Dataweave Tutorial that covers how to set Sample Data on the Transform Message and use the preview pane to get a real-time feedback of the output generated by your Dataweave code, and other useful topics. How can we achieve the required output by using Lambdas, Reduce, mapObject, functions or any other operation of choice, other than the restricted methods/usage shown above. Programatically with an if condition (this is for field by field mapping) var b = null --- { a: 1, (b: b) if b != null, c: 3 } Share. However, DataWeave is also available in other contexts, like as a command-line tool. mapObject : The Only difference between Pluck and mapObject is that mapObject returns an Object instead of an Array.
Dataweave (nested) map conditional mapping.
Hot Network Questions Is it safe to have pedal cage reaching wheel when slightly turned?.
Merge Fields from Separate Objects.
Returns true if the given input value is empty, false if not. The XML data structure is mapped to DataWeave objects that can contain other objects, strings, or null values. The result is an array of elements: The first matching the entire regex, the second matching the initial capture group in the the regex, the third matching the last capture group ([a-z]). Returns an array of keys from key-value pairs within the input object. Map function is used to iterate on an array of objects and it returns a transformed array of objects as an output after applying any . The DW you tried should work if you wrap the expression in parenthesis. MuleSoft embodies DataWeave in …. The global variables are the ones that appear over the three dashes (---) that separate your script. 0; output application / json; fun recursivefunction (data, keyName, fieldsToMask) = data match {case is Array-> data map recursivefunction ($, null, fieldsToMask) case is Object-> data mapObject {($$): recursivefunction ($, $$, …. Concatenation is when you link two strings, objects, data types etc together in a chain or …. The output of the mapObject mapping transformation collates the input objects key, value and index as shown in figure 3. camelize from the String library to apply a camel case format to strings (all words stringed together, using upper case letters to mark separations). In this case, the key address doesn’t have a null value.
How can I update a specific XML node in dataweave, without re ….
How to map an array within an array and achieve the following ….
In other words, we're going to pass a function into our existing function to specify exactly how we want it to work. Mulesoft Dataweave map object to array. You can use DataWeave to save these responses as variables, and pass them to other systems as needed. If you want to use the parse the strings as JSON you need whatever application that uses the input to be able to parse it. The as operator is also featured in this example. Step 1: Use an api which will give you a.
How to create "HashMap" instance Object in Mule 4 / DataWeave ….
For other DataWeave versions, you can use the version selector in the DataWeave table of contents. In this case, the function sent sets. The problem I am having with the following dataweave is that my output array only has 1 entry and I want each {key :, forecast:} in their own object entry in the array. output application/json skipNullOn="everywhere" --- payload. mapObject provides an example that coerces a string to a number and formats the number.
0 how to create nested array from flat array.
The Mule app consists of: A Scheduler component that triggers the flow. For array, the DataWeave engine maps each element. var results = payload groupBy ( (item, index) -> item. First let's remember some definitions of streaming in DataWeave: The basic unit of the stream is specific to the data format.
DataWeave: the mapObject function.
When on each user, it uses two other mapObject functions to process the fields in both personal information and login information. Dataweave key value set from database to HashMap.
0 mapObject recursion match JSON values.
the real data is much more huge and complex. 0 output application/json --- payload update { case.
Common Reusable Dataweave Scripts – Part 1.
I had a similar solution but I was curious to see if there are any dataweave operations which enabled us to do this. **Date = { ( DateAttribute_5ccef6de-d3c4-45a7-b538-c06dd55e4097 map {. I have some xml that I am transforming to json. We need to write mask on field level basis 2. The reason why I was trying to use Dataweave was that it seems to be the direction Mulesoft is learning towards for data transformation. One source could pass in an empty collection/array, which then gets passed to the output generated by dataweave. Consider using the official MuleSoft Developer docs. DataWeave map function: How to iterate through all items in an Array ; DataWeave mapObject function: How to transform key/value pairs in an Object ; DataWeave pluck function: How to transform an Object into an Array ; DataWeave reduce function: How to loop through and transform an Array into a different type. It applies the DataWeave upper function to those values. Your input doesnt match your dw script so it's hard to tell, there is no namespaces and "customers" element is missing. 1 Answer Sorted by: 2 We don't even need to map: input: [ { "id": 12, "name": "sun", "age": 25 }, { "id": 13, "name": "moon", "age": 25 }, { "id": 14, "name": "pluto", "age": 28 } ] …. For all other cases, we leave the value as is.
Map function in Dataweave.
as I need to do another point to point mapping from xml to xml for each element but that Mapping is creating an extra map where B is null also. Filter in dataweave used to return the matching values as per the expression applied. How to convert JSON object to Json Array using dataweave 2. A couple of nested flatMaps to map the array levels above the key to filter, then filter and extract the value from the key you want: %dw 2. This could be as simple as checking whether certain field(s)/attribute(s) in the input payload are empty or null, then setting a …. Type mismatch for 'mapObject' operator found :array, :function required :object, :function. JSON transformation via Dataweave. Here is another way which i have tried. Either of the arrays can also have mixed-type elements.
How to remove an entry from JSON using dataweave?.
May I know the syntax for checking a value is null or empty in data weave. Under the hood, DataWeave creates a brand new structure, keeping unaltered fields the same and updating the ones you selected. Hi, I have a scenario where I have to add objects to an array if they are not present. The following example formats the output of the DataWeave function to show supported letters: %dw 2. The anonymous function (value, index) → {index: value} maps each item in the input to an object. Iterates over an object using a mapper that . The DataWeave example defines a function in the DataWeave header that removes a specific XML attribute from the passed element and its children. When in deferred mode, DataWeave can also pass streamed. Featured Solutions API Management Manage and secure any API, built and deployed anywhere Integration Connect any system, data, or API to integrate at scale Automation Automate processes and tasks for every team MuleSoft AI Connect data and automate workflows with AI Featured Integration Salesforce Power connected …. Please advise how to learn data weave from scratch. The base function the applies the received function onto the keys of the received element and also to every one of its child elements recursively. 0: Iterate array inside objects of arrays. The DataWeave script selects XML content from specified namespaces. is there a way to update a specific node in via dataweave? I want to do something like. Some interesting changes have been made for these functions in . Merges an array into a single string value and uses the provided string as a separator between each item in the list.
Mapping a JSON in Dataweave 2.
dataweave convert ArrayList to Map issue.
An example is @Since(version = "2. the mapObject DataWeave function; Contrast DataWeave and Java mapping operations; the p DataWeave function (application properties) the pluck DataWeave function. elem mapObject { ($$): filterEmptyObjects($) } Basically, it maps one object into another one. 1 Our limitation is we are not using Enterprise edition only community edition So cannot use Transform component. DataWeave Reference; dw::Core; isEmpty. The match statement behaves like a match or switch statement in other languages, like Java or C++, and routes an input expression to a particular output expression based on some conditions. 0 %input payload application/json %output application/xml --- { root: { (payload map { node1: …. map (Array, ( (T, Number) -> R)): Array. How can i increment variable value inside function mapobject datawave 2. Thank you for taking out time to read the above post. 0 %output application/json --- payload ++ {id : "123"} If you have to update child object you can use mapObject. It is primarily organized into sections …. to go through each object in the. The DataWeave script in the Transform Message component iterates over the array in the input payload and selects its zipcode values. Using the below dataweave function, you can ignore any empty values, objects or arrays that you want! You can update the case v is Array| Object | Null | "" to include any other cases you would like to skip over when outputting your payload. I create a function to simplify extracting what we want as attributes from the list. If any specific value is required on the basis of occurrence like the First Value or the Last value from the list for the key then an index can be used for that. It takes two parameters: an Array and a lambda. These variables are accessible from anywhere in. Provide the name testscript for the project, and click Finish. For the first part I'll just get the parts of the multipart and discard everything else: payload. There are two ways to denote it. DataWeave represents data using values, each of which has a data type associated with it. How to do mapping as arraylist of maps for below using dataweave mule. Checks if an expression matches the entire input string. You can read more about me here. I am a MuleSoft Certified Developer & Architect working in Billennium. All that I need to do is if my flow variable is holding xml or not null then I need to add elements of xml in the dataweave otherwise don't add. This example returns the key, value, and attributes from the object specified in the variable myVar. These examples show how to use standalone DataWeave to extract and transform data. map having two arg - item and index. DataWeave 1; Upvote; Answer; Share; 3 answers; 9 views; Top Rated Answers.
DataWeave filter function: How to filter items in an Array">DataWeave filter function: How to filter items in an Array.
Useful for mapping an object into an array, pluck iterates over an object and returns an array of keys, values, or indices from the object. Uses mapObject to go through the keys and values in each object, and set all the keys to …. This can be set through an attribute in the output directive named skipNullOn, which can. When you know the root key, you can just use hard code that and concatenate strings. How do I append in DataWeave? › In DataWeave 2. How do I set a variable based on the value in the payload? 2.
mapObject function in DataWeave 2.
It in fact contains an Object with more key/value pairs. Hot Network Questions What attracted Abimelech to an old woman in her 80s or 90s?. How to remove empty array objects from dataweave response. 0 output application/json /** * Updates the value of the specified field If the field doesn't exits it will be inserted at the bottom. Note: Same Script can be used for dataweave version 1. The key thinking of solve this kind of problem how to group, sort, and extract values from the Array or LinkedHashMap. Object takes two parametes a value and key, and returns a new Object.
Converting Array object to string using dataweave 2.
following xml is stored in a variable "AddressCheckXml" as a "%dw 2.