SlideShare a Scribd company logo
1 of 16
By Anirban Sen Chowdhary
.
Here I will show you how ……
Before we start we will look what is a JSON and how JSON
payload looks like.
JSON (JavaScript Object Notation) is a lightweight data-
interchange format. It is easy for humans to read and write.
JSON is a text format that is completely language independent
but uses conventions that are familiar to programmers of the
C-family of languages, including C, C++, C#, Java, JavaScript,
Perl, Python, and many others. These properties make JSON an
ideal data-interchange language.
Source :- http://www.json.org/
JSON payload looks like :-
{
"id" : 1,
"name" : "Anirban",
"age" : 29,
"email" : "anirban1234@gmail.com",
"Designation": "SSE"
}
We can use a Mule component called json:is-json-filter in our
flow to validate a JSON payload
So, we can take following Mule flow to demonstrate :-
As you can see there is a flow and a sub flow. A message filter is there after
the file inbound filter which wrap a json:is-json-filter in it to validate the
JSON payload. We will use file inbound endpoint in our flow to pick file
containing JSON payloads
The subflow is used for throwing a message in case the payload is an invalid
JSON content
The corresponding Mule flow will be :-
<file:connector name="File_Global" autoDelete="true"
outputAppend="true" streaming="true" validateConnections="true"
doc:name="File" />
<sub-flow name="ValidationFailFlow" doc:name="ValidationFailFlow">
<logger message="Please provide valid JSON Content" level="INFO"
doc:name="Logger" />
<set-payload
value="Message has been rejected by filter ... Please provide valid JSON Content"
doc:name="Set Payload" />
</sub-flow>
<flow name="JSONValidationFlow" doc:name="restConsumeFlow">
<file:inbound-endpoint path="E:backuptest"
responseTimeout="10000" doc:name="File" connector-ref="File_Global">
<file:filename-regex-filter pattern="complex.json"
caseSensitive="false" />
</file:inbound-endpoint>
<message-filter onUnaccepted="ValidationFailFlow"
doc:name="Message">
<json:is-json-filter />
</message-filter>
<logger message="Valid JSON" level="INFO" doc:name="Logger" />
</flow>
So, let us consider we use the following JSON as a payload and
keep it as a file named complex.json in E:backuptest
location-
{
"id" : 1,
"name" : "Anirban",
"age" : 29,
"email" : "anirban1234@gmail.com",
"Designation": "SSE"
}
Since it is a valid JSON content we will get the following in our
console
Now, if we test our application we with an invalid JSON like :-
{
"id" : 1,
"name" : "Anirban",
"age" : 29
"email" : "anirban1234@gmail.com",
"Designation": "SSE"
}
You can see the above JSON is invalid as I deliberately deleted
the comma between the attributes to make it as invalid. Now
we save this JSON in our complex.json in E:backuptest so
that file inbound endpoint picks it up.
Now our Mule application throws the following message in
console :
Now when we execute this flow, we will get the above in our console
Hope you enjoyed the simple yet an amazing trick in Mule
Validating a json in mule

More Related Content

What's hot

How To Embed SlideShare Shows Into WordPress.com
How To Embed SlideShare Shows Into WordPress.comHow To Embed SlideShare Shows Into WordPress.com
How To Embed SlideShare Shows Into WordPress.com
Kathy Gill
 
Website Development Process
Website Development ProcessWebsite Development Process
Website Development Process
Hend Al-Khalifa
 

What's hot (20)

Intro to power apps
Intro to power appsIntro to power apps
Intro to power apps
 
Why HATEOAS
Why HATEOASWhy HATEOAS
Why HATEOAS
 
Oracle APEX Social Login
Oracle APEX Social LoginOracle APEX Social Login
Oracle APEX Social Login
 
MuleSoft JWT Demystified
MuleSoft JWT DemystifiedMuleSoft JWT Demystified
MuleSoft JWT Demystified
 
Http methods
Http methodsHttp methods
Http methods
 
Building Next-Generation Web APIs with JSON-LD and Hydra
Building Next-Generation Web APIs with JSON-LD and HydraBuilding Next-Generation Web APIs with JSON-LD and Hydra
Building Next-Generation Web APIs with JSON-LD and Hydra
 
Java script
Java scriptJava script
Java script
 
#CNX14 - Introducing CloudPages – How CloudPages Helps Drive Acquisition, Eng...
#CNX14 - Introducing CloudPages – How CloudPages Helps Drive Acquisition, Eng...#CNX14 - Introducing CloudPages – How CloudPages Helps Drive Acquisition, Eng...
#CNX14 - Introducing CloudPages – How CloudPages Helps Drive Acquisition, Eng...
 
Php Tutorials for Beginners
Php Tutorials for BeginnersPhp Tutorials for Beginners
Php Tutorials for Beginners
 
How To Embed SlideShare Shows Into WordPress.com
How To Embed SlideShare Shows Into WordPress.comHow To Embed SlideShare Shows Into WordPress.com
How To Embed SlideShare Shows Into WordPress.com
 
Bootstrap 5 ppt
Bootstrap 5 pptBootstrap 5 ppt
Bootstrap 5 ppt
 
Website Development Process
Website Development ProcessWebsite Development Process
Website Development Process
 
PowerApps
PowerAppsPowerApps
PowerApps
 
Rest API
Rest APIRest API
Rest API
 
Front End Development | Introduction
Front End Development | IntroductionFront End Development | Introduction
Front End Development | Introduction
 
Rest and the hypermedia constraint
Rest and the hypermedia constraintRest and the hypermedia constraint
Rest and the hypermedia constraint
 
Microsoft PowerApps
Microsoft PowerAppsMicrosoft PowerApps
Microsoft PowerApps
 
Discover Salesforce Commerce Cloud and Vlocity Integration Patterns
Discover Salesforce Commerce Cloud and Vlocity Integration PatternsDiscover Salesforce Commerce Cloud and Vlocity Integration Patterns
Discover Salesforce Commerce Cloud and Vlocity Integration Patterns
 
Automated testing APEX Applications
Automated testing APEX ApplicationsAutomated testing APEX Applications
Automated testing APEX Applications
 
JSON-LD for RESTful services
JSON-LD for RESTful servicesJSON-LD for RESTful services
JSON-LD for RESTful services
 

Similar to Validating a json in mule

JSON Fuzzing: New approach to old problems
JSON Fuzzing: New  approach to old problemsJSON Fuzzing: New  approach to old problems
JSON Fuzzing: New approach to old problems
titanlambda
 
Con fess 2013-sse-websockets-json-bhakti
Con fess 2013-sse-websockets-json-bhaktiCon fess 2013-sse-websockets-json-bhakti
Con fess 2013-sse-websockets-json-bhakti
Bhakti Mehta
 
Java Script Based Client Server Webapps 2
Java Script Based Client Server Webapps 2Java Script Based Client Server Webapps 2
Java Script Based Client Server Webapps 2
kriszyp
 
JavaScript Lessons 2023 V2
JavaScript Lessons 2023 V2JavaScript Lessons 2023 V2
JavaScript Lessons 2023 V2
Laurence Svekis ✔
 
module 2.pptx for full stack mobile development application on backend applic...
module 2.pptx for full stack mobile development application on backend applic...module 2.pptx for full stack mobile development application on backend applic...
module 2.pptx for full stack mobile development application on backend applic...
HemaSenthil5
 

Similar to Validating a json in mule (20)

JSON Fuzzing: New approach to old problems
JSON Fuzzing: New  approach to old problemsJSON Fuzzing: New  approach to old problems
JSON Fuzzing: New approach to old problems
 
Json
JsonJson
Json
 
Converting with custom transformer part 2
Converting with custom transformer part 2Converting with custom transformer part 2
Converting with custom transformer part 2
 
Con fess 2013-sse-websockets-json-bhakti
Con fess 2013-sse-websockets-json-bhaktiCon fess 2013-sse-websockets-json-bhakti
Con fess 2013-sse-websockets-json-bhakti
 
Json
JsonJson
Json
 
Java Script Based Client Server Webapps 2
Java Script Based Client Server Webapps 2Java Script Based Client Server Webapps 2
Java Script Based Client Server Webapps 2
 
Advanced Json
Advanced JsonAdvanced Json
Advanced Json
 
Pythonlearn-13-WebServices.pptx
Pythonlearn-13-WebServices.pptxPythonlearn-13-WebServices.pptx
Pythonlearn-13-WebServices.pptx
 
JavaScript Lessons 2023 V2
JavaScript Lessons 2023 V2JavaScript Lessons 2023 V2
JavaScript Lessons 2023 V2
 
Encrypting/Decrypting mule
Encrypting/Decrypting  muleEncrypting/Decrypting  mule
Encrypting/Decrypting mule
 
JSON-(JavaScript Object Notation)
JSON-(JavaScript Object Notation)JSON-(JavaScript Object Notation)
JSON-(JavaScript Object Notation)
 
Mule parsing with json part2
Mule parsing with json part2Mule parsing with json part2
Mule parsing with json part2
 
Json parser
Json parserJson parser
Json parser
 
module 2.pptx for full stack mobile development application on backend applic...
module 2.pptx for full stack mobile development application on backend applic...module 2.pptx for full stack mobile development application on backend applic...
module 2.pptx for full stack mobile development application on backend applic...
 
[WSO2 Integration Summit Nairobi 2019] Ballerina - Cloud Native Programming L...
[WSO2 Integration Summit Nairobi 2019] Ballerina - Cloud Native Programming L...[WSO2 Integration Summit Nairobi 2019] Ballerina - Cloud Native Programming L...
[WSO2 Integration Summit Nairobi 2019] Ballerina - Cloud Native Programming L...
 
Json
JsonJson
Json
 
Introduction to JSON
Introduction to JSONIntroduction to JSON
Introduction to JSON
 
Json tutorial, a beguiner guide
Json tutorial, a beguiner guideJson tutorial, a beguiner guide
Json tutorial, a beguiner guide
 
Converting with custom transformer
Converting with custom transformerConverting with custom transformer
Converting with custom transformer
 
Android and REST
Android and RESTAndroid and REST
Android and REST
 

More from Anirban Sen Chowdhary

More from Anirban Sen Chowdhary (20)

Change the game with Game changer
Change the game with Game changerChange the game with Game changer
Change the game with Game changer
 
Ring central desktop app overview
Ring central desktop app overviewRing central desktop app overview
Ring central desktop app overview
 
Overview in ringcentral digital line
Overview in ringcentral digital lineOverview in ringcentral digital line
Overview in ringcentral digital line
 
Some basics with ring central
Some basics with ring centralSome basics with ring central
Some basics with ring central
 
Ring central and python
Ring central and pythonRing central and python
Ring central and python
 
RingCentral application development overview
RingCentral application development overviewRingCentral application development overview
RingCentral application development overview
 
Cloze connect ringcentral
Cloze connect ringcentralCloze connect ringcentral
Cloze connect ringcentral
 
Overview on ring central errors part 4
Overview on ring central errors part 4Overview on ring central errors part 4
Overview on ring central errors part 4
 
Setting up your ring central sandbox in steps
Setting up your ring central sandbox in stepsSetting up your ring central sandbox in steps
Setting up your ring central sandbox in steps
 
Overview on ring central errors: part 2
Overview on ring central errors: part 2Overview on ring central errors: part 2
Overview on ring central errors: part 2
 
Overview on ring central errors
Overview on ring central errorsOverview on ring central errors
Overview on ring central errors
 
Call recording overview ring central
Call recording overview  ring centralCall recording overview  ring central
Call recording overview ring central
 
Ring central engaging with amazon alexa
Ring central engaging with amazon alexaRing central engaging with amazon alexa
Ring central engaging with amazon alexa
 
How ring central sdk changing the game
How ring central sdk changing the gameHow ring central sdk changing the game
How ring central sdk changing the game
 
When ring central connect salesforce
When ring central connect salesforceWhen ring central connect salesforce
When ring central connect salesforce
 
Mule 4 connecting ring central
Mule 4 connecting ring centralMule 4 connecting ring central
Mule 4 connecting ring central
 
Ring central sdk
Ring central sdkRing central sdk
Ring central sdk
 
Ring central with okta
Ring central with oktaRing central with okta
Ring central with okta
 
Ring central connecting salesforce overview
Ring central connecting salesforce overviewRing central connecting salesforce overview
Ring central connecting salesforce overview
 
Ring central call logs overview (part 2)
Ring central call logs overview (part 2)Ring central call logs overview (part 2)
Ring central call logs overview (part 2)
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 

Validating a json in mule

  • 1. By Anirban Sen Chowdhary
  • 2.
  • 3. .
  • 4. Here I will show you how ……
  • 5. Before we start we will look what is a JSON and how JSON payload looks like. JSON (JavaScript Object Notation) is a lightweight data- interchange format. It is easy for humans to read and write. JSON is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others. These properties make JSON an ideal data-interchange language. Source :- http://www.json.org/
  • 6. JSON payload looks like :- { "id" : 1, "name" : "Anirban", "age" : 29, "email" : "anirban1234@gmail.com", "Designation": "SSE" }
  • 7. We can use a Mule component called json:is-json-filter in our flow to validate a JSON payload
  • 8. So, we can take following Mule flow to demonstrate :- As you can see there is a flow and a sub flow. A message filter is there after the file inbound filter which wrap a json:is-json-filter in it to validate the JSON payload. We will use file inbound endpoint in our flow to pick file containing JSON payloads
  • 9. The subflow is used for throwing a message in case the payload is an invalid JSON content
  • 10. The corresponding Mule flow will be :- <file:connector name="File_Global" autoDelete="true" outputAppend="true" streaming="true" validateConnections="true" doc:name="File" /> <sub-flow name="ValidationFailFlow" doc:name="ValidationFailFlow"> <logger message="Please provide valid JSON Content" level="INFO" doc:name="Logger" /> <set-payload value="Message has been rejected by filter ... Please provide valid JSON Content" doc:name="Set Payload" /> </sub-flow> <flow name="JSONValidationFlow" doc:name="restConsumeFlow"> <file:inbound-endpoint path="E:backuptest" responseTimeout="10000" doc:name="File" connector-ref="File_Global"> <file:filename-regex-filter pattern="complex.json" caseSensitive="false" /> </file:inbound-endpoint> <message-filter onUnaccepted="ValidationFailFlow" doc:name="Message"> <json:is-json-filter /> </message-filter> <logger message="Valid JSON" level="INFO" doc:name="Logger" /> </flow>
  • 11. So, let us consider we use the following JSON as a payload and keep it as a file named complex.json in E:backuptest location- { "id" : 1, "name" : "Anirban", "age" : 29, "email" : "anirban1234@gmail.com", "Designation": "SSE" }
  • 12. Since it is a valid JSON content we will get the following in our console
  • 13. Now, if we test our application we with an invalid JSON like :- { "id" : 1, "name" : "Anirban", "age" : 29 "email" : "anirban1234@gmail.com", "Designation": "SSE" } You can see the above JSON is invalid as I deliberately deleted the comma between the attributes to make it as invalid. Now we save this JSON in our complex.json in E:backuptest so that file inbound endpoint picks it up.
  • 14. Now our Mule application throws the following message in console : Now when we execute this flow, we will get the above in our console
  • 15. Hope you enjoyed the simple yet an amazing trick in Mule