{"id":15256,"date":"2019-10-24T10:17:53","date_gmt":"2019-10-24T03:17:53","guid":{"rendered":"https:\/\/huongdanjava.com\/?p=15256"},"modified":"2022-06-14T06:49:24","modified_gmt":"2022-06-13T23:49:24","slug":"using-reduce-function-in-dataweave","status":"publish","type":"post","link":"https:\/\/huongdanjava.com\/using-reduce-function-in-dataweave.html","title":{"rendered":"Using reduce() function in DataWeave"},"content":{"rendered":"<p>The reduce() function in DataWeave 1 and 2 is a function that helps us able to manipulate the elements of an array and output the type of data that we want.<\/p>\n<p>To do this, the parameters of the reduce() function include the item in the array we are going to manipulate and the second parameter accumulator will store and define the type of data we want to return. The structure of the reduce() function is written in a Lambda Expression style from Java 8 as follows:<\/p>\n<pre class=\"lang:java decode:true\">&lt;input&gt; reduce (item, acc) -&gt; &lt;...&gt;<\/pre>\n<p>In which, &lt;input&gt; is the array that we will manipulate. The reduce() function will loop through all the items of the array, and for each item, it will perform the operation defined in the body of the Lambda Expression. The value of the acc parameter, if we don&#8217;t define an initial value for it, its value will start from the value of the first element of the array and we can define the return data type using this acc parameter, for example as follows:<\/p>\n<pre class=\"lang:java decode:true\">acc = {}<\/pre>\n<p>for Object object,<\/p>\n<pre class=\"lang:java decode:true \">acc = []<\/pre>\n<p>for array and<\/p>\n<pre class=\"lang:java decode:true \">acc = \"\"<\/pre>\n<p>for String.<\/p>\n<p>For example, I have the following array:<\/p>\n<pre class=\"lang:java decode:true \">var arr = [1, 2, 3, 4]<\/pre>\n<p>If we do nothing:<\/p>\n<pre class=\"lang:java decode:true\">%dw 2.0\r\noutput application\/json\r\nvar arr = [1, 2, 3, 4]\r\n---\r\n{\r\n\titem: arr reduce ((item, acc) -&gt; item),\r\n\tacc: arr reduce((item, acc) -&gt; acc)\r\n}<\/pre>\n<p>then the last value of the item parameter will be the value of the last element in the array, and the last value of the acc parameter will be the value of the first element in the array.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-15258 size-full\" src=\"https:\/\/huongdanjava.com\/wp-content\/uploads\/2019\/10\/using-reduce-function-in-dataweave-1.png\" alt=\"Using reduce() function in DataWeave\" width=\"700\" height=\"282\" \/><\/p>\n<p>If you want to sum, concatenate, reverse the string, you can write the code as follows:<\/p>\n<pre class=\"lang:java decode:true\">%dw 2.0\r\noutput application\/json\r\nvar arr = [1, 2, 3, 4]\r\n---\r\n{\r\n\tsum: arr reduce ((item, acc) -&gt; acc + item),\r\n\tconcat: arr reduce((item, acc) -&gt; acc ++ item),\r\n\treverse: arr reduce((item, acc) -&gt; item ++ acc)\r\n}<\/pre>\n<p>Result:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-15259 size-full\" src=\"https:\/\/huongdanjava.com\/wp-content\/uploads\/2019\/10\/using-reduce-function-in-dataweave-2.png\" alt=\"Using reduce() function in DataWeave\" width=\"700\" height=\"265\" \/><\/p>\n<p>The definition of the operation before or after the acc parameter plus defining the output in this parameter will help us get the desired result, DataWeave will rely on these definitions to return results.<\/p>\n<p>By default, the value of the acc parameter will be the value of the first element in the array, but if you set it to the initial value, for example:<\/p>\n<pre class=\"lang:java decode:true \">%dw 2.0\r\noutput application\/json\r\nvar arr = [1, 2, 3, 4]\r\n---\r\n{\r\n\tsum: arr reduce ((item, acc = 2) -&gt; acc + item)\r\n}<\/pre>\n<p>then the initial value of the parameter acc will be this value.<\/p>\n<p>As the above example, I assigned the parameter acc an initial value of 2, so when calculating the sum of the elements of the array above, the final value will be is 12:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-15260 size-full\" src=\"https:\/\/huongdanjava.com\/wp-content\/uploads\/2019\/10\/using-reduce-function-in-dataweave-3.png\" alt=\"Using reduce() function in DataWeave\" width=\"700\" height=\"268\" \/><\/p>\n<p>If you have an object similar to the following:<\/p>\n<pre class=\"lang:java decode:true \">var students = [\r\n    { \"name\": \"Khanh\", \"age\": 32 }, \r\n    { \"name\": \"Quan\", \"age\": 25 } \r\n]<\/pre>\n<p>and you want the output to be an array of student names, you can code the following:<\/p>\n<pre class=\"lang:java decode:true \">%dw 2.0\r\noutput application\/json\r\nvar students = [\r\n    { \"name\": \"Khanh\", \"age\": 32 }, \r\n    { \"name\": \"Quan\", \"age\": 25 } \r\n]\r\n---\r\n{\r\n\tnames: students reduce ((item, acc=[]) -&gt; acc + item)\r\n}<\/pre>\n<p>Here, we are defining the return data type for the acc parameter as an array, so the output will see the following result:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-15261 size-full\" src=\"https:\/\/huongdanjava.com\/wp-content\/uploads\/2019\/10\/using-reduce-function-in-dataweave-4.png\" alt=\"Using reduce() function in DataWeave\" width=\"700\" height=\"304\" \/><\/p>\n<p>You can also use the $ character to replace the array&#8217;s item parameter and $$ instead of the acc parameter when using the reduce() function, similar to <a href=\"https:\/\/huongdanjava.com\/using-pluck-function-in-dataweave-2.html\" target=\"_blank\" rel=\"noopener noreferrer\">the pluck() function in DataWeave<\/a>.<\/p>\n<p>We can write code using $ and $$ as follows:<\/p>\n<pre class=\"lang:java decode:true \">%dw 2.0\r\noutput application\/json\r\nvar arr = [1, 2, 3, 4]\r\n---\r\n{\r\n\tsum: arr reduce ($$ + $)\r\n}<\/pre>\n<p>The result is still the same:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-15262 size-full\" src=\"https:\/\/huongdanjava.com\/wp-content\/uploads\/2019\/10\/using-reduce-function-in-dataweave-5.png\" alt=\"Using reduce() function in DataWeave\" width=\"700\" height=\"268\" \/><\/p>\n\n\n<div class=\"kk-star-ratings kksr-auto kksr-align-right kksr-valign-bottom\"\n    data-payload='{&quot;align&quot;:&quot;right&quot;,&quot;id&quot;:&quot;15256&quot;,&quot;slug&quot;:&quot;default&quot;,&quot;valign&quot;:&quot;bottom&quot;,&quot;ignore&quot;:&quot;&quot;,&quot;reference&quot;:&quot;auto&quot;,&quot;class&quot;:&quot;&quot;,&quot;count&quot;:&quot;0&quot;,&quot;legendonly&quot;:&quot;&quot;,&quot;readonly&quot;:&quot;&quot;,&quot;score&quot;:&quot;0&quot;,&quot;starsonly&quot;:&quot;&quot;,&quot;best&quot;:&quot;5&quot;,&quot;gap&quot;:&quot;4&quot;,&quot;greet&quot;:&quot;&quot;,&quot;legend&quot;:&quot;0\\\/5 - (0 votes)&quot;,&quot;size&quot;:&quot;24&quot;,&quot;title&quot;:&quot;Using reduce() function in DataWeave&quot;,&quot;width&quot;:&quot;0&quot;,&quot;_legend&quot;:&quot;{score}\\\/{best} - ({count} {votes})&quot;,&quot;font_factor&quot;:&quot;1.25&quot;}'>\n            \n<div class=\"kksr-stars\">\n    \n<div class=\"kksr-stars-inactive\">\n            <div class=\"kksr-star\" data-star=\"1\" style=\"padding-right: 4px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"2\" style=\"padding-right: 4px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"3\" style=\"padding-right: 4px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"4\" style=\"padding-right: 4px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" data-star=\"5\" style=\"padding-right: 4px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n    <\/div>\n    \n<div class=\"kksr-stars-active\" style=\"width: 0px;\">\n            <div class=\"kksr-star\" style=\"padding-right: 4px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 4px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 4px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 4px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n            <div class=\"kksr-star\" style=\"padding-right: 4px\">\n            \n\n<div class=\"kksr-icon\" style=\"width: 24px; height: 24px;\"><\/div>\n        <\/div>\n    <\/div>\n<\/div>\n                \n\n<div class=\"kksr-legend\" style=\"font-size: 19.2px;\">\n            <span class=\"kksr-muted\"><\/span>\n    <\/div>\n    <\/div>\n","protected":false},"excerpt":{"rendered":"<p>The reduce() function in DataWeave 1 and 2 is a function that helps us able to manipulate the elements of an array and output the type of data that we want. To do this, the parameters of the reduce() function include the item in the&hellip; <a href=\"https:\/\/huongdanjava.com\/using-reduce-function-in-dataweave.html\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":8070,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[440],"tags":[],"class_list":["post-15256","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-mule-esb-en","clearfix"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Using reduce() function in DataWeave - Huong Dan Java<\/title>\n<meta name=\"description\" content=\"In this tutorial, I will guide you all how to use reduce() function in DataWeave.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/huongdanjava.com\/using-reduce-function-in-dataweave.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Using reduce() function in DataWeave - Huong Dan Java\" \/>\n<meta property=\"og:description\" content=\"In this tutorial, I will guide you all how to use reduce() function in DataWeave.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/huongdanjava.com\/using-reduce-function-in-dataweave.html\" \/>\n<meta property=\"og:site_name\" content=\"Huong Dan Java\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/nhkhanh2406\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/nhkhanh2406\" \/>\n<meta property=\"article:published_time\" content=\"2019-10-24T03:17:53+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-06-13T23:49:24+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/huongdanjava.com\/wp-content\/uploads\/2018\/03\/mule.png\" \/>\n\t<meta property=\"og:image:width\" content=\"400\" \/>\n\t<meta property=\"og:image:height\" content=\"400\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Khanh Nguyen\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/KhanhNguyenJ\" \/>\n<meta name=\"twitter:site\" content=\"@KhanhNguyenJ\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Khanh Nguyen\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/huongdanjava.com\\\/using-reduce-function-in-dataweave.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/huongdanjava.com\\\/using-reduce-function-in-dataweave.html\"},\"author\":{\"name\":\"Khanh Nguyen\",\"@id\":\"https:\\\/\\\/huongdanjava.com\\\/#\\\/schema\\\/person\\\/dc859d7f8cbea3b593e6738de9cbb82d\"},\"headline\":\"Using reduce() function in DataWeave\",\"datePublished\":\"2019-10-24T03:17:53+00:00\",\"dateModified\":\"2022-06-13T23:49:24+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/huongdanjava.com\\\/using-reduce-function-in-dataweave.html\"},\"wordCount\":448,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\\\/\\\/huongdanjava.com\\\/#\\\/schema\\\/person\\\/dc859d7f8cbea3b593e6738de9cbb82d\"},\"image\":{\"@id\":\"https:\\\/\\\/huongdanjava.com\\\/using-reduce-function-in-dataweave.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/huongdanjava.com\\\/wp-content\\\/uploads\\\/2018\\\/03\\\/mule.png\",\"articleSection\":[\"Mule ESB\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/huongdanjava.com\\\/using-reduce-function-in-dataweave.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/huongdanjava.com\\\/using-reduce-function-in-dataweave.html\",\"url\":\"https:\\\/\\\/huongdanjava.com\\\/using-reduce-function-in-dataweave.html\",\"name\":\"Using reduce() function in DataWeave - Huong Dan Java\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/huongdanjava.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/huongdanjava.com\\\/using-reduce-function-in-dataweave.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/huongdanjava.com\\\/using-reduce-function-in-dataweave.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/huongdanjava.com\\\/wp-content\\\/uploads\\\/2018\\\/03\\\/mule.png\",\"datePublished\":\"2019-10-24T03:17:53+00:00\",\"dateModified\":\"2022-06-13T23:49:24+00:00\",\"description\":\"In this tutorial, I will guide you all how to use reduce() function in DataWeave.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/huongdanjava.com\\\/using-reduce-function-in-dataweave.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/huongdanjava.com\\\/using-reduce-function-in-dataweave.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/huongdanjava.com\\\/using-reduce-function-in-dataweave.html#primaryimage\",\"url\":\"https:\\\/\\\/huongdanjava.com\\\/wp-content\\\/uploads\\\/2018\\\/03\\\/mule.png\",\"contentUrl\":\"https:\\\/\\\/huongdanjava.com\\\/wp-content\\\/uploads\\\/2018\\\/03\\\/mule.png\",\"width\":400,\"height\":400},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/huongdanjava.com\\\/using-reduce-function-in-dataweave.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/huongdanjava.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Using reduce() function in DataWeave\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/huongdanjava.com\\\/#website\",\"url\":\"https:\\\/\\\/huongdanjava.com\\\/\",\"name\":\"Huong Dan Java\",\"description\":\"Java development tutorials\",\"publisher\":{\"@id\":\"https:\\\/\\\/huongdanjava.com\\\/#\\\/schema\\\/person\\\/dc859d7f8cbea3b593e6738de9cbb82d\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/huongdanjava.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/huongdanjava.com\\\/#\\\/schema\\\/person\\\/dc859d7f8cbea3b593e6738de9cbb82d\",\"name\":\"Khanh Nguyen\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/huongdanjava.com\\\/wp-content\\\/uploads\\\/2021\\\/07\\\/CC6FAC58-D227-4DD8-93D1-6D6A795577E3_1_201_a.jpeg\",\"url\":\"https:\\\/\\\/huongdanjava.com\\\/wp-content\\\/uploads\\\/2021\\\/07\\\/CC6FAC58-D227-4DD8-93D1-6D6A795577E3_1_201_a.jpeg\",\"contentUrl\":\"https:\\\/\\\/huongdanjava.com\\\/wp-content\\\/uploads\\\/2021\\\/07\\\/CC6FAC58-D227-4DD8-93D1-6D6A795577E3_1_201_a.jpeg\",\"width\":1267,\"height\":1517,\"caption\":\"Khanh Nguyen\"},\"logo\":{\"@id\":\"https:\\\/\\\/huongdanjava.com\\\/wp-content\\\/uploads\\\/2021\\\/07\\\/CC6FAC58-D227-4DD8-93D1-6D6A795577E3_1_201_a.jpeg\"},\"description\":\"I love Java and everything related to Java.\",\"sameAs\":[\"https:\\\/\\\/huongdanjava.com\",\"https:\\\/\\\/www.facebook.com\\\/nhkhanh2406\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/KhanhNguyenJ\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Using reduce() function in DataWeave - Huong Dan Java","description":"In this tutorial, I will guide you all how to use reduce() function in DataWeave.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/huongdanjava.com\/using-reduce-function-in-dataweave.html","og_locale":"en_US","og_type":"article","og_title":"Using reduce() function in DataWeave - Huong Dan Java","og_description":"In this tutorial, I will guide you all how to use reduce() function in DataWeave.","og_url":"https:\/\/huongdanjava.com\/using-reduce-function-in-dataweave.html","og_site_name":"Huong Dan Java","article_publisher":"https:\/\/www.facebook.com\/nhkhanh2406","article_author":"https:\/\/www.facebook.com\/nhkhanh2406","article_published_time":"2019-10-24T03:17:53+00:00","article_modified_time":"2022-06-13T23:49:24+00:00","og_image":[{"width":400,"height":400,"url":"https:\/\/huongdanjava.com\/wp-content\/uploads\/2018\/03\/mule.png","type":"image\/png"}],"author":"Khanh Nguyen","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/KhanhNguyenJ","twitter_site":"@KhanhNguyenJ","twitter_misc":{"Written by":"Khanh Nguyen","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/huongdanjava.com\/using-reduce-function-in-dataweave.html#article","isPartOf":{"@id":"https:\/\/huongdanjava.com\/using-reduce-function-in-dataweave.html"},"author":{"name":"Khanh Nguyen","@id":"https:\/\/huongdanjava.com\/#\/schema\/person\/dc859d7f8cbea3b593e6738de9cbb82d"},"headline":"Using reduce() function in DataWeave","datePublished":"2019-10-24T03:17:53+00:00","dateModified":"2022-06-13T23:49:24+00:00","mainEntityOfPage":{"@id":"https:\/\/huongdanjava.com\/using-reduce-function-in-dataweave.html"},"wordCount":448,"commentCount":2,"publisher":{"@id":"https:\/\/huongdanjava.com\/#\/schema\/person\/dc859d7f8cbea3b593e6738de9cbb82d"},"image":{"@id":"https:\/\/huongdanjava.com\/using-reduce-function-in-dataweave.html#primaryimage"},"thumbnailUrl":"https:\/\/huongdanjava.com\/wp-content\/uploads\/2018\/03\/mule.png","articleSection":["Mule ESB"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/huongdanjava.com\/using-reduce-function-in-dataweave.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/huongdanjava.com\/using-reduce-function-in-dataweave.html","url":"https:\/\/huongdanjava.com\/using-reduce-function-in-dataweave.html","name":"Using reduce() function in DataWeave - Huong Dan Java","isPartOf":{"@id":"https:\/\/huongdanjava.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/huongdanjava.com\/using-reduce-function-in-dataweave.html#primaryimage"},"image":{"@id":"https:\/\/huongdanjava.com\/using-reduce-function-in-dataweave.html#primaryimage"},"thumbnailUrl":"https:\/\/huongdanjava.com\/wp-content\/uploads\/2018\/03\/mule.png","datePublished":"2019-10-24T03:17:53+00:00","dateModified":"2022-06-13T23:49:24+00:00","description":"In this tutorial, I will guide you all how to use reduce() function in DataWeave.","breadcrumb":{"@id":"https:\/\/huongdanjava.com\/using-reduce-function-in-dataweave.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/huongdanjava.com\/using-reduce-function-in-dataweave.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/huongdanjava.com\/using-reduce-function-in-dataweave.html#primaryimage","url":"https:\/\/huongdanjava.com\/wp-content\/uploads\/2018\/03\/mule.png","contentUrl":"https:\/\/huongdanjava.com\/wp-content\/uploads\/2018\/03\/mule.png","width":400,"height":400},{"@type":"BreadcrumbList","@id":"https:\/\/huongdanjava.com\/using-reduce-function-in-dataweave.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/huongdanjava.com\/"},{"@type":"ListItem","position":2,"name":"Using reduce() function in DataWeave"}]},{"@type":"WebSite","@id":"https:\/\/huongdanjava.com\/#website","url":"https:\/\/huongdanjava.com\/","name":"Huong Dan Java","description":"Java development tutorials","publisher":{"@id":"https:\/\/huongdanjava.com\/#\/schema\/person\/dc859d7f8cbea3b593e6738de9cbb82d"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/huongdanjava.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/huongdanjava.com\/#\/schema\/person\/dc859d7f8cbea3b593e6738de9cbb82d","name":"Khanh Nguyen","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/huongdanjava.com\/wp-content\/uploads\/2021\/07\/CC6FAC58-D227-4DD8-93D1-6D6A795577E3_1_201_a.jpeg","url":"https:\/\/huongdanjava.com\/wp-content\/uploads\/2021\/07\/CC6FAC58-D227-4DD8-93D1-6D6A795577E3_1_201_a.jpeg","contentUrl":"https:\/\/huongdanjava.com\/wp-content\/uploads\/2021\/07\/CC6FAC58-D227-4DD8-93D1-6D6A795577E3_1_201_a.jpeg","width":1267,"height":1517,"caption":"Khanh Nguyen"},"logo":{"@id":"https:\/\/huongdanjava.com\/wp-content\/uploads\/2021\/07\/CC6FAC58-D227-4DD8-93D1-6D6A795577E3_1_201_a.jpeg"},"description":"I love Java and everything related to Java.","sameAs":["https:\/\/huongdanjava.com","https:\/\/www.facebook.com\/nhkhanh2406","https:\/\/x.com\/https:\/\/twitter.com\/KhanhNguyenJ"]}]}},"_links":{"self":[{"href":"https:\/\/huongdanjava.com\/wp-json\/wp\/v2\/posts\/15256","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/huongdanjava.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/huongdanjava.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/huongdanjava.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/huongdanjava.com\/wp-json\/wp\/v2\/comments?post=15256"}],"version-history":[{"count":8,"href":"https:\/\/huongdanjava.com\/wp-json\/wp\/v2\/posts\/15256\/revisions"}],"predecessor-version":[{"id":20278,"href":"https:\/\/huongdanjava.com\/wp-json\/wp\/v2\/posts\/15256\/revisions\/20278"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/huongdanjava.com\/wp-json\/wp\/v2\/media\/8070"}],"wp:attachment":[{"href":"https:\/\/huongdanjava.com\/wp-json\/wp\/v2\/media?parent=15256"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/huongdanjava.com\/wp-json\/wp\/v2\/categories?post=15256"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/huongdanjava.com\/wp-json\/wp\/v2\/tags?post=15256"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}