SlideShare a Scribd company logo
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.
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 !!!….

More Related Content

PPTX
Creating dynamic json in Mule
 
PPTX
Dataweave
PPTX
Converting with custom transformer
PPTX
Json to json transformation in mule
PPTX
RunSignup Domains
PPTX
Mule esb csv_to_json
PDF
Simplify, Isolate and Scale with RabbitMQ
PPTX
File tostring conversion
Creating dynamic json in Mule
 
Dataweave
Converting with custom transformer
Json to json transformation in mule
RunSignup Domains
Mule esb csv_to_json
Simplify, Isolate and Scale with RabbitMQ
File tostring conversion

What's hot (6)

PPTX
Soap request in mule
DOCX
HOSTING
PPTX
Web Services and Mobile
PPTX
Example esb file-to-string flow
KEY
Devoxx - JSON Validation using JSON Schema and Jackson
PPTX
Setting filedynamically
Soap request in mule
HOSTING
Web Services and Mobile
Example esb file-to-string flow
Devoxx - JSON Validation using JSON Schema and Jackson
Setting filedynamically
Ad

Viewers also liked (13)

PPTX
All roads lead to IP (Commercialization) - Kurt Shuler, Arteris
PDF
Object based
PPTX
Ipa 8 bab 4
PDF
ECB final presentation (LinkedIn version)
PDF
อัจฉรา เชี่ยนมั่น 55670055
DOC
St6200 data specification-www.ttbvs.com
PDF
นางสาวพัชรี เพ็ชร์อุดม 55670194 กลุ่ม 3301
PDF
[월간금융] 스마트워크 필수활용팁(1)
PDF
Raytheon-NCSA_Millennial_Survey_report_2014
DOCX
noticias
PPTX
Ecuaciones diferenciales aplicadas a la ingeniería civil
PPTX
LIQUIDOS Y ELECTROLITOS CORPORALES
PDF
Sesión 1 gonzález, f. y villegas, m. (2008). cómo elaborar proyectos de inves...
All roads lead to IP (Commercialization) - Kurt Shuler, Arteris
Object based
Ipa 8 bab 4
ECB final presentation (LinkedIn version)
อัจฉรา เชี่ยนมั่น 55670055
St6200 data specification-www.ttbvs.com
นางสาวพัชรี เพ็ชร์อุดม 55670194 กลุ่ม 3301
[월간금융] 스마트워크 필수활용팁(1)
Raytheon-NCSA_Millennial_Survey_report_2014
noticias
Ecuaciones diferenciales aplicadas a la ingeniería civil
LIQUIDOS Y ELECTROLITOS CORPORALES
Sesión 1 gonzález, f. y villegas, m. (2008). cómo elaborar proyectos de inves...
Ad

Similar to Json (20)

PPTX
Creating dynamic json in mule
PPTX
Creating dynamic json
PPTX
Creating dynamic json
PPTX
Creating dynamic json
PPTX
Creating dynamic json
PPTX
Creating dynamic json
PPTX
Creating dynamic json
PPTX
Creating dynamic json
PPTX
Creating dynamic json
PPTX
Creating dynamic json
PPTX
Create dynamic json using mule
PPTX
Json to json transformation in mule
PPTX
Transformation jsontojsonesb
PPTX
Transformation jsontojsonesb
PPTX
Transformation jsontojsonesb
PDF
Mule esb and_relevant_components
PDF
Mulesoft ppt
PDF
Mule ESB Interview or Certification questions
PPTX
Converting with custom transformer part 2
PPTX
Json to json esb transformation
Creating dynamic json in mule
Creating dynamic json
Creating dynamic json
Creating dynamic json
Creating dynamic json
Creating dynamic json
Creating dynamic json
Creating dynamic json
Creating dynamic json
Creating dynamic json
Create dynamic json using mule
Json to json transformation in mule
Transformation jsontojsonesb
Transformation jsontojsonesb
Transformation jsontojsonesb
Mule esb and_relevant_components
Mulesoft ppt
Mule ESB Interview or Certification questions
Converting with custom transformer part 2
Json to json esb transformation

Recently uploaded (20)

PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PDF
Well-logging-methods_new................
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
DOCX
573137875-Attendance-Management-System-original
PPTX
bas. eng. economics group 4 presentation 1.pptx
PPT
Mechanical Engineering MATERIALS Selection
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PPTX
Sustainable Sites - Green Building Construction
PPTX
Construction Project Organization Group 2.pptx
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
Automation-in-Manufacturing-Chapter-Introduction.pdf
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
CYBER-CRIMES AND SECURITY A guide to understanding
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
Well-logging-methods_new................
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
573137875-Attendance-Management-System-original
bas. eng. economics group 4 presentation 1.pptx
Mechanical Engineering MATERIALS Selection
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
Sustainable Sites - Green Building Construction
Construction Project Organization Group 2.pptx
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
Operating System & Kernel Study Guide-1 - converted.pdf

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 !!!….