dataweave

Why does Mule DataWeave array map strip top level objects?

大兔子大兔子 提交于 2019-12-10 17:35:24
问题 I'm trying to understand the behaviour of DataWeave v1.0 when it comes to mapping objects in a root JSON array. At this stage I just want to map each item in the array as-is without mapping each individual field of the item. I need to do it for each item in the array because later on I want to edit some of the fields, but since there are potentially many I don't want the overhead of mapping them one-by-one. This is my dataweave: %dw 1.0 %output application/json --- payload map { ($) } This is

How to filter an array of JSON in Mule DataWeave

北战南征 提交于 2019-12-10 15:57:57
问题 I am having a JSON like this : { "dcsId": "1184001100000000517", "marketCode": "US", "languageCode": "en-US", "profile": { "base": { "username": "arunima27", "activeInd": "R", "phone": [ { "activeInd": "Y", "type": "mobile", "primaryInd": "Y", "number": "2234566788" }, { "activeInd": "N", "type": "mobile", "primaryInd": "N", "number": "" } ] } } } From this input JSON we need to extract the payload.profile.base.phone.number where the payload.profile.base.phone.type == "mobile" and payload

Ignore and log CSV row in DataWeave if condition is met

帅比萌擦擦* 提交于 2019-12-07 07:41:31
In DataWeave, is it possible to ignore a particular row in a CSV file if a condition is met. I'm transforming a file where some rows need to be ignored because a column has a value indicating a particular row shouldn't be mapped to the output. What I want to do in this scenario is skip that row, log (if possible) and then move on to mapping the next row. I've looked through the docs and the closest I've found to an answer is wrapping the mapping in a when otherwise clause. I can't find anything about calling a logger or even passing that particular row to a flow for processing (so it can be

Converting to a date format in Mule using DataWeave

夙愿已清 提交于 2019-12-04 04:36:33
问题 My requirement is to convert a string to a date format using DataWeave in Mule Input string 8/30/2015 4:00:13 PM Output date needs to be in MM/DD/YYYY format i.e, 08/30/2015 i have tried using the below logic (($[1] splitBy " ")[0]) as :date{format:"[m01]/[d01]/[y0001]"} this gave the error Exception while executing: "Order Date":(($[1] splitBy " ")[0]) as :date{format:"[m01]/[d01]/[y0001]"}, Cannot coerce a :string to a :date ^ I am using Mule Anypoint Studio Version: 5.2.0 回答1: First you

How to ignore empty objects in DataWeave Mule esb

て烟熏妆下的殇ゞ 提交于 2019-11-30 14:09:44
问题 I am working on transforming my payload. I have got the situation here. Input payload looks like this below one:- { "address": { "city": "bab", "company_name": "asdast", "country_code": "sam", "location": { "city": null, "state": null } }} I used %output application/json skipNullOn = "everywhere" it returns me JSON like below { "address": { "city": "bab", "company_name": "asdast", "country_code": "sam", "location": { } }} But I don't want to have empty location object if all fields in

How to ignore empty objects in DataWeave Mule esb

守給你的承諾、 提交于 2019-11-30 09:29:49
I am working on transforming my payload. I have got the situation here. Input payload looks like this below one:- { "address": { "city": "bab", "company_name": "asdast", "country_code": "sam", "location": { "city": null, "state": null } }} I used %output application/json skipNullOn = "everywhere" it returns me JSON like below { "address": { "city": "bab", "company_name": "asdast", "country_code": "sam", "location": { } }} But I don't want to have empty location object if all fields in location objects are empty.I am expecting something like this { "address": { "city": "bab", "company_name":