SlideShare a Scribd company logo
Creating Dynamic JSON in Mule
Mule ESB has multiple options to create dynamic payload. The payload used in Mule can be of
multiple types like JSON, XML or simple Text payload.
With Mule we can dynamically generate any type of payload at any point of time in the flow.
We will see how to create a simple JSON payload dynamically within a Mule flow and post that JSON
to an external service and get a response.
It’s quite simple and we will see how we can generate a JSON in a flow.
Creating dynamic json
Let us consider we need to create a JSON file as following :-
{
"myService": {
"messageHeader": {
"messageId": "ec75da88e64a739e12c126",
"messageDateTime": "2014-09-18T14:07:46+0530"
},
"mesageBody": {
"myServiceRequest": {
"Amount": 3520,
"ConsumerId": "ABC-T14005-AFF",
"Timestamp": "2014-10-27T18:36:18+0700"
}
}
}
}
Now, we need to create this flow in our Mule flow and send the JSON request created to the external service
and will get a response. We will assign the JSON elements value from flow variables for now, but you can use
message inbound properties or other ways to assign the flow variables dynamically within the flow.
We will use Mule Expression Transformer to create this JSON request. As per Mule documentation here
https://developer.mulesoft.com/docs/display/current/Expression+Transformer+Reference :-
The Expression Transformer executes one or more expressions on the current message. The results of these
expressions becomes the payload of the current message.
Let’s consider our Mule flow as following :-
Here you can see, the expression transformer is creating the JSON request which is send to the external web service. The
flow variables are used to set the value and you can assign the variables dynamically in your way.
Now let’s test our flow by placing by hitting the url http://localhost:8085/rc/test on browser as
follows, :-
The JSON request will be generated in the flow and with that request it will be posted to the external
web service which will return a response
Now, we can see in our logger the JSON request generated and the JSON response from the external
service in return :-
So, here you can see how to set a Dynamic JSON and can be send to the external service to get a
response…. you can try this with your requirement as well and set the value dynamically in the flow
variables or can use other dynamic options like inbound properties etc !!!….
In my next slide I will bring some other techniques in Mule implementation .
Hope you have enjoyed this simpler version.
Keep sharing your knowledge and let our Mule community grow 
Creating dynamic json

More Related Content

PPTX
Converting with custom transformer
PPTX
Json
PPTX
Mule parsing with json
PPTX
Creating dynamic json in Mule
 
PPTX
Mule parsing with json part2
PPTX
Mule: JSON to Object
PPTX
Dataweave
PPTX
Json to json transformation in mule
Converting with custom transformer
Json
Mule parsing with json
Creating dynamic json in Mule
 
Mule parsing with json part2
Mule: JSON to Object
Dataweave
Json to json transformation in mule

What's hot (14)

PPTX
Mule requesterdemo
PPTX
Mapping and listing with mule
PDF
Simplify, Isolate and Scale with RabbitMQ
PPTX
Playing with cxf interceptor in mule
PPTX
Playing with cxf interceptor in mule
PPTX
Synchronous communication using jms back channel
PPTX
Mule esb csv_to_json
PDF
PHP client - Mongo db User Group Pune
PPTX
Servicestack
PPTX
File tostring conversion
PDF
Asynchronous JavaScript loading
PPTX
Ws security with mule
PPTX
Demystifying JSON in SQL Server
TXT
Mule requesterdemo
Mapping and listing with mule
Simplify, Isolate and Scale with RabbitMQ
Playing with cxf interceptor in mule
Playing with cxf interceptor in mule
Synchronous communication using jms back channel
Mule esb csv_to_json
PHP client - Mongo db User Group Pune
Servicestack
File tostring conversion
Asynchronous JavaScript loading
Ws security with mule
Demystifying JSON in SQL Server
Ad

Viewers also liked (14)

DOCX
Cleaning Resume 2403
PPTX
Groovy with mule
DOCX
Looking Back At L’Oréal
DOCX
Trabajo de cultura ciudadana
PDF
Leren en samenwerken in de strafrechtketen
PPTX
Mule with drools
PPTX
Caching and invalidating with managed store
DOCX
Trabajo de cultura ciudadana
PPTX
Tipo de cambio
PPTX
Jenkins
PDF
Crossing Boundaries - Identifying antecedents of intra and inter team learnin...
PDF
Gate 2016 S1 exam paper
PPTX
Validate soap request in mule
PPTX
Converting with custom transformer
Cleaning Resume 2403
Groovy with mule
Looking Back At L’Oréal
Trabajo de cultura ciudadana
Leren en samenwerken in de strafrechtketen
Mule with drools
Caching and invalidating with managed store
Trabajo de cultura ciudadana
Tipo de cambio
Jenkins
Crossing Boundaries - Identifying antecedents of intra and inter team learnin...
Gate 2016 S1 exam paper
Validate soap request in mule
Converting with custom transformer
Ad

Similar to Creating dynamic json (20)

PPTX
Create dynamic json using mule
PPTX
Creating dynamic json
PPTX
Splitting with mule part2
PPTX
Soap request in mule
PPTX
Validating a soap request in mule
PPTX
Validating soap request in mule
PPTX
Validate soap request in mule
PPTX
Validating a soap request in mule
PPTX
Validating a soap request in mule
PPTX
Validating soap request in mule
PPTX
Validate soap request in mule
PPTX
Validate Soap Request in Mule
PPTX
Web application with mule
PPTX
Json to json transformation in mule
PPTX
Webapplicationwithmule by raju
PPTX
Transformation jsontojsonesb
PPTX
Transformation jsontojsonesb
PPTX
Using ajax in mule
PPTX
Webapplicationwithmule by nagarjuanreddy
PPTX
Soap In Mule
Create dynamic json using mule
Creating dynamic json
Splitting with mule part2
Soap request in mule
Validating a soap request in mule
Validating soap request in mule
Validate soap request in mule
Validating a soap request in mule
Validating a soap request in mule
Validating soap request in mule
Validate soap request in mule
Validate Soap Request in Mule
Web application with mule
Json to json transformation in mule
Webapplicationwithmule by raju
Transformation jsontojsonesb
Transformation jsontojsonesb
Using ajax in mule
Webapplicationwithmule by nagarjuanreddy
Soap In Mule

More from Hasan Syed (16)

PPTX
Xslt in mule
PPTX
Web service vm in mule
PPTX
Simple web service vm
PPTX
Scatter gather flow control
PPTX
Mule with velocity
PPTX
Mule with rabbit mq
PPTX
Mule with quartz
PPTX
Mule esb
PPTX
Maven iii
PPTX
Maven ii
PPTX
Maven part 1
PPTX
Jenkins3
PPTX
Jenkins2
PPTX
Idempotent filter with simple file
PPTX
Cache for community edition
PPTX
Automatic documentation with mule
Xslt in mule
Web service vm in mule
Simple web service vm
Scatter gather flow control
Mule with velocity
Mule with rabbit mq
Mule with quartz
Mule esb
Maven iii
Maven ii
Maven part 1
Jenkins3
Jenkins2
Idempotent filter with simple file
Cache for community edition
Automatic documentation with mule

Recently uploaded (20)

PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
Spectroscopy.pptx food analysis technology
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Big Data Technologies - Introduction.pptx
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Encapsulation theory and applications.pdf
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
KodekX | Application Modernization Development
PPTX
Cloud computing and distributed systems.
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Spectroscopy.pptx food analysis technology
Unlocking AI with Model Context Protocol (MCP)
Mobile App Security Testing_ A Comprehensive Guide.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Agricultural_Statistics_at_a_Glance_2022_0.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Machine learning based COVID-19 study performance prediction
Big Data Technologies - Introduction.pptx
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Encapsulation theory and applications.pdf
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Per capita expenditure prediction using model stacking based on satellite ima...
20250228 LYD VKU AI Blended-Learning.pptx
Dropbox Q2 2025 Financial Results & Investor Presentation
KodekX | Application Modernization Development
Cloud computing and distributed systems.

Creating dynamic json

  • 2. Mule ESB has multiple options to create dynamic payload. The payload used in Mule can be of multiple types like JSON, XML or simple Text payload. With Mule we can dynamically generate any type of payload at any point of time in the flow. We will see how to create a simple JSON payload dynamically within a Mule flow and post that JSON to an external service and get a response. It’s quite simple and we will see how we can generate a JSON in a flow.
  • 4. Let us consider we need to create a JSON file as following :- { "myService": { "messageHeader": { "messageId": "ec75da88e64a739e12c126", "messageDateTime": "2014-09-18T14:07:46+0530" }, "mesageBody": { "myServiceRequest": { "Amount": 3520, "ConsumerId": "ABC-T14005-AFF", "Timestamp": "2014-10-27T18:36:18+0700" } } } } Now, we need to create this flow in our Mule flow and send the JSON request created to the external service and will get a response. We will assign the JSON elements value from flow variables for now, but you can use message inbound properties or other ways to assign the flow variables dynamically within the flow.
  • 5. We will use Mule Expression Transformer to create this JSON request. As per Mule documentation here https://developer.mulesoft.com/docs/display/current/Expression+Transformer+Reference :- The Expression Transformer executes one or more expressions on the current message. The results of these expressions becomes the payload of the current message.
  • 6. Let’s consider our Mule flow as following :- Here you can see, the expression transformer is creating the JSON request which is send to the external web service. The flow variables are used to set the value and you can assign the variables dynamically in your way.
  • 7. Now let’s test our flow by placing by hitting the url http://localhost:8085/rc/test on browser as follows, :- The JSON request will be generated in the flow and with that request it will be posted to the external web service which will return a response
  • 8. Now, we can see in our logger the JSON request generated and the JSON response from the external service in return :-
  • 9. So, here you can see how to set a Dynamic JSON and can be send to the external service to get a response…. you can try this with your requirement as well and set the value dynamically in the flow variables or can use other dynamic options like inbound properties etc !!!….
  • 10. In my next slide I will bring some other techniques in Mule implementation . Hope you have enjoyed this simpler version. Keep sharing your knowledge and let our Mule community grow 