SlideShare a Scribd company logo
1 of 9
Mule Concepts
DataWeave VII
• Pattern matching executes on the first pattern that
matches the specified expression.
• DataWeave supports four different types of patterns:
– Literal
– type/traits
– Regex
– Expression
• Each pattern type can be either named or
unnamed.
DataWeave – Body - Pattern matching
• The example below is a model for how matching
works :
---
value match {
(<name>:)?<pattern> -> <when matched>,
(<name>:)?<pattern> -> <when matched>,
default -> <when none of them matched>
}
---
DataWeave – Body - Pattern matching
• Literal Pattern :
– Matches when the evaluated value equals a simple literal value.
– Example :
– In this example, the first field simply matches the value in
'payload.string' and returns a boolean, the second field performs the
same match, but returns an object that contains both a boolean and a
reference to the validated value.
DataWeave – Body - Pattern matching
Transform Input Output
%dw 1.0
%output application/json
---
a: payload.string match {
"Emiliano" -> true,
"Mariano" -> false
},
b: payload.string match {
str: "Emiliano" -> { "matches": true, value: str },
str: "Mariano" -> { "matches": false, value: str }
}
{ "string": "Emiliano" }
{
"a": true,
"b": {
"matches": true,
"value": "Emiliano"
}
}
• Expression Pattern :
– Matches when running a certain expression over the evaluated value
returns true.
– Example :
– In this example, the first field matches the value of 'payload.string' against two
alternatives and conditionally appends a different string to it; the second field
evaluates if the value in 'payload.number' is larger or smaller than 3 and
returns "lower" or "higher" accordingly.
DataWeave – Body - Pattern matching
Transform Input Output
%dw 1.0
%output application/json
---
{
a: payload.string match {
str when str == "Mariano" -> str ++ " de Achaval",
str when str == "Emiliano" -> str ++ " Lesende" },
b: payload.number match {
n when n < 3 -> "lower",
n when n > 3 -> "higher" }}
{
"string":
"Emiliano",
"number": 3.14
}
{
"a": "Emiliano
Lesende",
"b": "higher"
}
• Match Type :
– Matches when the evaluated value is of the specified type.
– Example :
DataWeave – Body - Pattern matching
Transform Input Output
%dw 1.0
%output application/json
---
{
a: payload.a match {
:object -> "OBJECT",
:string -> "STRING",
:number -> "NUMBER",
:boolean -> "BOOLEAN",
:array -> "ARRAY",
:null -> "NULL"
},
b: payload.b match {
y is :object -> { type: "OBJECT", y: y },
y is :string -> { type: "STRING", y: y },
y is :number -> { type: "NUMBER", y: y },
y is :boolean -> { type: "BOOLEAN", y: y },
y is :array -> { type: "ARRAY", y: y },
y is :null -> { type: "NULL", y: y }
}}
{
"a": "Emiliano",
"b": 3.14
}
{
"a": "STRING",
"b": {
"type": "NUMBER",
"y": 3.14
}
}
• Match Type :
– In this example, the first field evaluates the type of 'payload.a' and returns a
different string with the type name depending on what type it matches with
(this could be easier done through the Type Of operator), the second field
returns an object with the same type name as a string and a reference to the
evaluated value.
DataWeave – Body - Pattern matching
• Match Regex :
– Matches when the evaluated value fits a given regular expression.
– Example :
DataWeave – Body - Pattern matching
Transform Input Output
%dw 1.0
%output application/json
---
{
a: payload.phones map ($ match {
/+(d+)s((d+))s(d+-d+)/ -> { country: $[0], area:
$[1], number: $[2] },
/((d+))s(d+-d+)/ -> { area: $[1], number: $[2] }
}),
b: payload.phones map ($ match {
phone: /+(d+)s((d+))s(d+-d+)/ -> { country:
phone[0], area: phone[1], number: phone[2] },
phone: /((d+))s(d+-d+)/ -> { area: phone[1],
number: phone[2] }
})
}
{
"phones": [
"+1 (415) 229-
2009",
"(647) 456-
7008"
]
}
{
"a": [
{
"country": "+1 (415) 229-
2009","area": "1","number":
"415"
},{
"area": "647",
"number": "456-7008"
} ],
"b": [
{"country": "+1 (415) 229-
2009",
"area": "1",
"number": "415"},
{"area": "647",
"number": "456-7008" }]}
• Match Regex :
– In this example, the payload includes two elements in an array, and in both
cases the Map operatorto cycle through the array. It then evaluates each
element agains a regular expression and outputs a different object depending
on what kind of match is found.
DataWeave – Body - Pattern matching

More Related Content

Viewers also liked

Mule data weave_10
Mule data weave_10Mule data weave_10
Mule data weave_10kunal vishe
 
Mule scopes async_scope
Mule scopes async_scopeMule scopes async_scope
Mule scopes async_scopekunal vishe
 
Mule data weave_4
Mule data weave_4Mule data weave_4
Mule data weave_4kunal vishe
 
Mule data weave_2
Mule data weave_2Mule data weave_2
Mule data weave_2kunal vishe
 
10 Useful Asciidoctor Tips
10 Useful Asciidoctor Tips10 Useful Asciidoctor Tips
10 Useful Asciidoctor TipsAndres Almiray
 
Mule soft mel_session_3
Mule soft mel_session_3Mule soft mel_session_3
Mule soft mel_session_3abhipokharna
 

Viewers also liked (8)

Mule data weave_10
Mule data weave_10Mule data weave_10
Mule data weave_10
 
Mule scopes async_scope
Mule scopes async_scopeMule scopes async_scope
Mule scopes async_scope
 
Mule mel 3
Mule mel 3Mule mel 3
Mule mel 3
 
Mule mel 5_tips
Mule mel 5_tipsMule mel 5_tips
Mule mel 5_tips
 
Mule data weave_4
Mule data weave_4Mule data weave_4
Mule data weave_4
 
Mule data weave_2
Mule data weave_2Mule data weave_2
Mule data weave_2
 
10 Useful Asciidoctor Tips
10 Useful Asciidoctor Tips10 Useful Asciidoctor Tips
10 Useful Asciidoctor Tips
 
Mule soft mel_session_3
Mule soft mel_session_3Mule soft mel_session_3
Mule soft mel_session_3
 

Similar to Mule data weave_7

I just need answers for all TODO- I do not need any explanation or any.pdf
I just need answers for all TODO- I do not need any explanation or any.pdfI just need answers for all TODO- I do not need any explanation or any.pdf
I just need answers for all TODO- I do not need any explanation or any.pdfMattU5mLambertq
 
I just need answers for all TODO- I do not need any explanation or any (1).pdf
I just need answers for all TODO- I do not need any explanation or any (1).pdfI just need answers for all TODO- I do not need any explanation or any (1).pdf
I just need answers for all TODO- I do not need any explanation or any (1).pdfMattU5mLambertq
 
Regex startup
Regex startupRegex startup
Regex startupPayPal
 
Export Data using R Studio
Export Data using R StudioExport Data using R Studio
Export Data using R StudioRupak Roy
 
Regular expressions
Regular expressionsRegular expressions
Regular expressionsRaj Gupta
 
Read carefully. Im not sure if the point class is correct but postin.pdf
Read carefully. Im not sure if the point class is correct but postin.pdfRead carefully. Im not sure if the point class is correct but postin.pdf
Read carefully. Im not sure if the point class is correct but postin.pdfbharatchawla141
 
Real World Haskell: Lecture 4
Real World Haskell: Lecture 4Real World Haskell: Lecture 4
Real World Haskell: Lecture 4Bryan O'Sullivan
 
Stata Cheat Sheets (all)
Stata Cheat Sheets (all)Stata Cheat Sheets (all)
Stata Cheat Sheets (all)Laura Hughes
 
Java: Regular Expression
Java: Regular ExpressionJava: Regular Expression
Java: Regular ExpressionMasudul Haque
 
Chap1introppt2php(finally done)
Chap1introppt2php(finally done)Chap1introppt2php(finally done)
Chap1introppt2php(finally done)monikadeshmane
 
Validating JSON -- Percona Live 2021 presentation
Validating JSON -- Percona Live 2021 presentationValidating JSON -- Percona Live 2021 presentation
Validating JSON -- Percona Live 2021 presentationDave Stokes
 
Excel analysis assignment this is an independent assignment me
Excel analysis assignment this is an independent assignment meExcel analysis assignment this is an independent assignment me
Excel analysis assignment this is an independent assignment mejoney4
 

Similar to Mule data weave_7 (20)

I just need answers for all TODO- I do not need any explanation or any.pdf
I just need answers for all TODO- I do not need any explanation or any.pdfI just need answers for all TODO- I do not need any explanation or any.pdf
I just need answers for all TODO- I do not need any explanation or any.pdf
 
I just need answers for all TODO- I do not need any explanation or any (1).pdf
I just need answers for all TODO- I do not need any explanation or any (1).pdfI just need answers for all TODO- I do not need any explanation or any (1).pdf
I just need answers for all TODO- I do not need any explanation or any (1).pdf
 
Regex startup
Regex startupRegex startup
Regex startup
 
Working with shapes
Working with shapesWorking with shapes
Working with shapes
 
Mongo DB Presentation
Mongo DB PresentationMongo DB Presentation
Mongo DB Presentation
 
Export Data using R Studio
Export Data using R StudioExport Data using R Studio
Export Data using R Studio
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Read carefully. Im not sure if the point class is correct but postin.pdf
Read carefully. Im not sure if the point class is correct but postin.pdfRead carefully. Im not sure if the point class is correct but postin.pdf
Read carefully. Im not sure if the point class is correct but postin.pdf
 
Real World Haskell: Lecture 4
Real World Haskell: Lecture 4Real World Haskell: Lecture 4
Real World Haskell: Lecture 4
 
Stata Cheat Sheets (all)
Stata Cheat Sheets (all)Stata Cheat Sheets (all)
Stata Cheat Sheets (all)
 
WD programs descriptions.docx
WD programs descriptions.docxWD programs descriptions.docx
WD programs descriptions.docx
 
Java: Regular Expression
Java: Regular ExpressionJava: Regular Expression
Java: Regular Expression
 
Chap1introppt2php(finally done)
Chap1introppt2php(finally done)Chap1introppt2php(finally done)
Chap1introppt2php(finally done)
 
6.array
6.array6.array
6.array
 
Validating JSON -- Percona Live 2021 presentation
Validating JSON -- Percona Live 2021 presentationValidating JSON -- Percona Live 2021 presentation
Validating JSON -- Percona Live 2021 presentation
 
Sharbani bhattacharya VB Structures
Sharbani bhattacharya VB StructuresSharbani bhattacharya VB Structures
Sharbani bhattacharya VB Structures
 
vb.net.pdf
vb.net.pdfvb.net.pdf
vb.net.pdf
 
R language tutorial.pptx
R language tutorial.pptxR language tutorial.pptx
R language tutorial.pptx
 
Excel analysis assignment this is an independent assignment me
Excel analysis assignment this is an independent assignment meExcel analysis assignment this is an independent assignment me
Excel analysis assignment this is an independent assignment me
 
130717666736980000
130717666736980000130717666736980000
130717666736980000
 

More from kunal vishe

Mule scopes request_response_scope
Mule scopes request_response_scopeMule scopes request_response_scope
Mule scopes request_response_scopekunal vishe
 
Mule scopes foreach_scope
Mule scopes foreach_scopeMule scopes foreach_scope
Mule scopes foreach_scopekunal vishe
 
Mule debugging logging_configuration_in_mule
Mule debugging logging_configuration_in_muleMule debugging logging_configuration_in_mule
Mule debugging logging_configuration_in_mulekunal vishe
 
Mule debugging logging_in_mule
Mule debugging logging_in_muleMule debugging logging_in_mule
Mule debugging logging_in_mulekunal vishe
 
Mule debugging managing_stack_traces
Mule debugging managing_stack_tracesMule debugging managing_stack_traces
Mule debugging managing_stack_traceskunal vishe
 
Mule error handling_rollback exception strategy
Mule error handling_rollback exception strategyMule error handling_rollback exception strategy
Mule error handling_rollback exception strategykunal vishe
 
Mule error handling_choice exception strategy
Mule error handling_choice exception strategyMule error handling_choice exception strategy
Mule error handling_choice exception strategykunal vishe
 
Mule concepts exception strategies
Mule concepts exception strategiesMule concepts exception strategies
Mule concepts exception strategieskunal vishe
 
Mule concepts filters scopes_routers
Mule concepts filters scopes_routersMule concepts filters scopes_routers
Mule concepts filters scopes_routerskunal vishe
 
Mule concepts transformers
Mule concepts transformersMule concepts transformers
Mule concepts transformerskunal vishe
 
Mule concepts components
Mule concepts componentsMule concepts components
Mule concepts componentskunal vishe
 
Mule concepts connectors
Mule concepts connectorsMule concepts connectors
Mule concepts connectorskunal vishe
 
Mule concepts elements in a mule flow
Mule concepts elements in a mule flowMule concepts elements in a mule flow
Mule concepts elements in a mule flowkunal vishe
 
Mule concepts flows
Mule concepts flowsMule concepts flows
Mule concepts flowskunal vishe
 

More from kunal vishe (20)

Mule mel 4_tips
Mule mel 4_tipsMule mel 4_tips
Mule mel 4_tips
 
Mule mel 2
Mule mel 2Mule mel 2
Mule mel 2
 
Mule mel 1
Mule mel 1Mule mel 1
Mule mel 1
 
Mule scopes request_response_scope
Mule scopes request_response_scopeMule scopes request_response_scope
Mule scopes request_response_scope
 
Mule scopes foreach_scope
Mule scopes foreach_scopeMule scopes foreach_scope
Mule scopes foreach_scope
 
Mule scopes 2
Mule scopes 2Mule scopes 2
Mule scopes 2
 
Mule scopes 1
Mule scopes 1Mule scopes 1
Mule scopes 1
 
Mule debugging logging_configuration_in_mule
Mule debugging logging_configuration_in_muleMule debugging logging_configuration_in_mule
Mule debugging logging_configuration_in_mule
 
Mule debugging logging_in_mule
Mule debugging logging_in_muleMule debugging logging_in_mule
Mule debugging logging_in_mule
 
Mule debugging managing_stack_traces
Mule debugging managing_stack_tracesMule debugging managing_stack_traces
Mule debugging managing_stack_traces
 
Mule error handling_rollback exception strategy
Mule error handling_rollback exception strategyMule error handling_rollback exception strategy
Mule error handling_rollback exception strategy
 
Mule message
Mule messageMule message
Mule message
 
Mule error handling_choice exception strategy
Mule error handling_choice exception strategyMule error handling_choice exception strategy
Mule error handling_choice exception strategy
 
Mule concepts exception strategies
Mule concepts exception strategiesMule concepts exception strategies
Mule concepts exception strategies
 
Mule concepts filters scopes_routers
Mule concepts filters scopes_routersMule concepts filters scopes_routers
Mule concepts filters scopes_routers
 
Mule concepts transformers
Mule concepts transformersMule concepts transformers
Mule concepts transformers
 
Mule concepts components
Mule concepts componentsMule concepts components
Mule concepts components
 
Mule concepts connectors
Mule concepts connectorsMule concepts connectors
Mule concepts connectors
 
Mule concepts elements in a mule flow
Mule concepts elements in a mule flowMule concepts elements in a mule flow
Mule concepts elements in a mule flow
 
Mule concepts flows
Mule concepts flowsMule concepts flows
Mule concepts flows
 

Recently uploaded

Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 

Recently uploaded (20)

Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 

Mule data weave_7

  • 2. • Pattern matching executes on the first pattern that matches the specified expression. • DataWeave supports four different types of patterns: – Literal – type/traits – Regex – Expression • Each pattern type can be either named or unnamed. DataWeave – Body - Pattern matching
  • 3. • The example below is a model for how matching works : --- value match { (<name>:)?<pattern> -> <when matched>, (<name>:)?<pattern> -> <when matched>, default -> <when none of them matched> } --- DataWeave – Body - Pattern matching
  • 4. • Literal Pattern : – Matches when the evaluated value equals a simple literal value. – Example : – In this example, the first field simply matches the value in 'payload.string' and returns a boolean, the second field performs the same match, but returns an object that contains both a boolean and a reference to the validated value. DataWeave – Body - Pattern matching Transform Input Output %dw 1.0 %output application/json --- a: payload.string match { "Emiliano" -> true, "Mariano" -> false }, b: payload.string match { str: "Emiliano" -> { "matches": true, value: str }, str: "Mariano" -> { "matches": false, value: str } } { "string": "Emiliano" } { "a": true, "b": { "matches": true, "value": "Emiliano" } }
  • 5. • Expression Pattern : – Matches when running a certain expression over the evaluated value returns true. – Example : – In this example, the first field matches the value of 'payload.string' against two alternatives and conditionally appends a different string to it; the second field evaluates if the value in 'payload.number' is larger or smaller than 3 and returns "lower" or "higher" accordingly. DataWeave – Body - Pattern matching Transform Input Output %dw 1.0 %output application/json --- { a: payload.string match { str when str == "Mariano" -> str ++ " de Achaval", str when str == "Emiliano" -> str ++ " Lesende" }, b: payload.number match { n when n < 3 -> "lower", n when n > 3 -> "higher" }} { "string": "Emiliano", "number": 3.14 } { "a": "Emiliano Lesende", "b": "higher" }
  • 6. • Match Type : – Matches when the evaluated value is of the specified type. – Example : DataWeave – Body - Pattern matching Transform Input Output %dw 1.0 %output application/json --- { a: payload.a match { :object -> "OBJECT", :string -> "STRING", :number -> "NUMBER", :boolean -> "BOOLEAN", :array -> "ARRAY", :null -> "NULL" }, b: payload.b match { y is :object -> { type: "OBJECT", y: y }, y is :string -> { type: "STRING", y: y }, y is :number -> { type: "NUMBER", y: y }, y is :boolean -> { type: "BOOLEAN", y: y }, y is :array -> { type: "ARRAY", y: y }, y is :null -> { type: "NULL", y: y } }} { "a": "Emiliano", "b": 3.14 } { "a": "STRING", "b": { "type": "NUMBER", "y": 3.14 } }
  • 7. • Match Type : – In this example, the first field evaluates the type of 'payload.a' and returns a different string with the type name depending on what type it matches with (this could be easier done through the Type Of operator), the second field returns an object with the same type name as a string and a reference to the evaluated value. DataWeave – Body - Pattern matching
  • 8. • Match Regex : – Matches when the evaluated value fits a given regular expression. – Example : DataWeave – Body - Pattern matching Transform Input Output %dw 1.0 %output application/json --- { a: payload.phones map ($ match { /+(d+)s((d+))s(d+-d+)/ -> { country: $[0], area: $[1], number: $[2] }, /((d+))s(d+-d+)/ -> { area: $[1], number: $[2] } }), b: payload.phones map ($ match { phone: /+(d+)s((d+))s(d+-d+)/ -> { country: phone[0], area: phone[1], number: phone[2] }, phone: /((d+))s(d+-d+)/ -> { area: phone[1], number: phone[2] } }) } { "phones": [ "+1 (415) 229- 2009", "(647) 456- 7008" ] } { "a": [ { "country": "+1 (415) 229- 2009","area": "1","number": "415" },{ "area": "647", "number": "456-7008" } ], "b": [ {"country": "+1 (415) 229- 2009", "area": "1", "number": "415"}, {"area": "647", "number": "456-7008" }]}
  • 9. • Match Regex : – In this example, the payload includes two elements in an array, and in both cases the Map operatorto cycle through the array. It then evaluates each element agains a regular expression and outputs a different object depending on what kind of match is found. DataWeave – Body - Pattern matching