SlideShare a Scribd company logo
JSON to JSON transformation in Mule
We often deals with JSON payloads in our
application on a large scale, specially whenever
we are exposing or consuming a REST API. One of
the common scenario we get is to modify or
transform the input JSON payload to another JSON
format and produce it as an output.
if we consider the following
{
"name": “Maurizio Rorato",
"id": 37
}
This is a simple JSON payload taken as an example,
which contains only 2 elements, that
is name and id.
So, if this JSON payload is coming into our
application as an input and we require to
transform/modify the payload into another JSON format
and produce it as an output, something like the following
{
"name": "John Rosso",
"id": 37,
"designation": "Director"
}
Where you can see the modified JSON has a new
element designation as a third element. The challenge here
is to modify the existing input JSON payload and
to design an output JSON payload from it, which will
contain this additional element in it with the same format.
So, the question is, how can be the input JSON format can
be modified or transformed in another JSON format that we
require, in a Mule application ??
The answer is Mule has a rich set of transformers and offers
different options to transform form one format of payload
into another. Mule also offers a powerful component
called Datamapper, which is limited to Mule enterprise
edition, and that can perform all these requirement in easy
way.
But here for Mule community edition, we will choose a
simplest way of doing it. We will be using Expression
Transformer for doing this.
Here is the following Mule flow, where we can
transform the JSON input into another JSON format.
So, you can transform from one JSON to another
dynamically using Expression transformer in the
following flow.
<flow name="DynamicJSONFlow1" doc:name="DynamicJSONFlow1">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost"
port="8085" path="test" doc:name="HTTP"/>
<json:json-to-object-transformer returnClass="java.lang.Object" doc:name="JSON
to Object"/>
<set-variable variableName="name" value="#[message.payload.name]"
doc:name="Variable"/>
<set-variable variableName="id" value="#[message.payload.id]"
doc:name="Variable"/>
<expression-transformer
expression="#[[
'name':flowVars.name,
'id':flowVars.id,
'designation':'Designation'
]
]" doc:name="Expression"/>
<json:object-to-json-transformer doc:name="Object to JSON"/>
<logger level="INFO" message="#[message.payload]"
doc:name="Logger"/>
</flow>
Transformation jsontojsonesb

More Related Content

Viewers also liked

第4回20130508 ch1
第4回20130508 ch1第4回20130508 ch1
第4回20130508 ch1youwatari
 
Eid soliman CV
Eid soliman CVEid soliman CV
Eid soliman CV
Eid Soliman
 
Passion Projects Jake
Passion Projects JakePassion Projects Jake
Passion Projects Jake
takahe2
 
Estadistica cto de asturias senior 2016
Estadistica cto de asturias senior 2016Estadistica cto de asturias senior 2016
Estadistica cto de asturias senior 2016
elmunu
 
Carbonless Printing & Handling
Carbonless Printing & HandlingCarbonless Printing & Handling
Carbonless Printing & HandlingNatureSolv
 
Fomento propició el caos de los controladores
Fomento propició el caos de los controladoresFomento propició el caos de los controladores
Fomento propició el caos de los controladoresEnmanuel Diaz
 
Color
ColorColor
Color
takahe2
 
Sys 42.10 Ft
Sys 42.10 FtSys 42.10 Ft
Sys 42.10 Ft
SYSTEEL
 
Km1639 091
Km1639 091Km1639 091
Km1639 091
Arany Tibor
 
Entorno virtual de aprendizaje
Entorno virtual de aprendizajeEntorno virtual de aprendizaje
Entorno virtual de aprendizaje
johanna quinaluisa
 
Métodos de recuperacion en el futbol
Métodos de recuperacion en el futbol Métodos de recuperacion en el futbol
Métodos de recuperacion en el futbol
Abel Lorenzo Agras
 
Decent femdom-exhibition
Decent femdom-exhibitionDecent femdom-exhibition
Decent femdom-exhibition
Tanya Boss
 
Advertsing 42 task 1
Advertsing 42 task 1Advertsing 42 task 1
Advertsing 42 task 1
Jo Lowes
 
Kaizen team leader guide
Kaizen team leader guideKaizen team leader guide
Kaizen team leader guideKobi Vider
 

Viewers also liked (16)

第4回20130508 ch1
第4回20130508 ch1第4回20130508 ch1
第4回20130508 ch1
 
Cle 2
Cle 2Cle 2
Cle 2
 
Eid soliman CV
Eid soliman CVEid soliman CV
Eid soliman CV
 
Passion Projects Jake
Passion Projects JakePassion Projects Jake
Passion Projects Jake
 
Estadistica cto de asturias senior 2016
Estadistica cto de asturias senior 2016Estadistica cto de asturias senior 2016
Estadistica cto de asturias senior 2016
 
Carbonless Printing & Handling
Carbonless Printing & HandlingCarbonless Printing & Handling
Carbonless Printing & Handling
 
Fomento propició el caos de los controladores
Fomento propició el caos de los controladoresFomento propició el caos de los controladores
Fomento propició el caos de los controladores
 
Color
ColorColor
Color
 
Sys 42.10 Ft
Sys 42.10 FtSys 42.10 Ft
Sys 42.10 Ft
 
Km1639 091
Km1639 091Km1639 091
Km1639 091
 
Descripción de tareas
Descripción de tareasDescripción de tareas
Descripción de tareas
 
Entorno virtual de aprendizaje
Entorno virtual de aprendizajeEntorno virtual de aprendizaje
Entorno virtual de aprendizaje
 
Métodos de recuperacion en el futbol
Métodos de recuperacion en el futbol Métodos de recuperacion en el futbol
Métodos de recuperacion en el futbol
 
Decent femdom-exhibition
Decent femdom-exhibitionDecent femdom-exhibition
Decent femdom-exhibition
 
Advertsing 42 task 1
Advertsing 42 task 1Advertsing 42 task 1
Advertsing 42 task 1
 
Kaizen team leader guide
Kaizen team leader guideKaizen team leader guide
Kaizen team leader guide
 

Similar to Transformation jsontojsonesb

Xml to xml transformation
Xml to xml transformationXml to xml transformation
Xml to xml transformation
Son Nguyen
 
Xml to xml transformation in mule
Xml to xml transformation in muleXml to xml transformation in mule
Xml to xml transformation in mule
mdfkhan625
 
Xml to xml transformation in mule
Xml to xml transformation in muleXml to xml transformation in mule
Xml to xml transformation in mule
Mohammed625
 
Xml to xml transformation in mule
Xml to xml transformation in muleXml to xml transformation in mule
Xml to xml transformation in mule
Rajkattamuri
 
Xml to xml transformation in mule
Xml to xml transformation in muleXml to xml transformation in mule
Xml to xml transformation in mule
javeed_mhd
 
Xml transform
Xml transformXml transform
Xml transform
Son Nguyen
 
Xml to xml transformation in mule
Xml to xml transformation in muleXml to xml transformation in mule
Xml to xml transformation in mule
Davide Rapacciuolo
 
Xml toobjectesbtransform
Xml toobjectesbtransformXml toobjectesbtransform
Xml toobjectesbtransform
Domenico Schiavone
 
Mule xml transformation
Mule xml transformationMule xml transformation
Mule xml transformation
D.Rajesh Kumar
 
Transformation xmltoobjectesb
Transformation xmltoobjectesbTransformation xmltoobjectesb
Transformation xmltoobjectesb
Antonio Pellegrino
 
Transformation xmltoobjectesb
Transformation xmltoobjectesbTransformation xmltoobjectesb
Transformation xmltoobjectesb
Germano Barba
 
Transformation xmltoobjectesb
Transformation xmltoobjectesbTransformation xmltoobjectesb
Transformation xmltoobjectesb
Davide Rapacciuolo
 
Transformation xmltoobjectesb
Transformation xmltoobjectesbTransformation xmltoobjectesb
Transformation xmltoobjectesb
Davide Rapacciuolo
 
Transform json to json
Transform json to jsonTransform json to json
Transform json to json
Son Nguyen
 
Json
JsonJson
Json
manavp
 
Converting with custom transformer
Converting with custom transformerConverting with custom transformer
Converting with custom transformer
javeed_mhd
 
Transforming with custom transformer in mule
Transforming with custom transformer in muleTransforming with custom transformer in mule
Transforming with custom transformer in mule
Praneethchampion
 
Converting with custom transformer
Converting with custom transformerConverting with custom transformer
Converting with custom transformer
Mohammed246
 
Converting with custom transformer
Converting with custom transformer Converting with custom transformer
Converting with custom transformer
AbdulImrankhan7
 
Converting with custom transforme
Converting with custom transformeConverting with custom transforme
Converting with custom transforme
Khasim Saheb
 

Similar to Transformation jsontojsonesb (20)

Xml to xml transformation
Xml to xml transformationXml to xml transformation
Xml to xml transformation
 
Xml to xml transformation in mule
Xml to xml transformation in muleXml to xml transformation in mule
Xml to xml transformation in mule
 
Xml to xml transformation in mule
Xml to xml transformation in muleXml to xml transformation in mule
Xml to xml transformation in mule
 
Xml to xml transformation in mule
Xml to xml transformation in muleXml to xml transformation in mule
Xml to xml transformation in mule
 
Xml to xml transformation in mule
Xml to xml transformation in muleXml to xml transformation in mule
Xml to xml transformation in mule
 
Xml transform
Xml transformXml transform
Xml transform
 
Xml to xml transformation in mule
Xml to xml transformation in muleXml to xml transformation in mule
Xml to xml transformation in mule
 
Xml toobjectesbtransform
Xml toobjectesbtransformXml toobjectesbtransform
Xml toobjectesbtransform
 
Mule xml transformation
Mule xml transformationMule xml transformation
Mule xml transformation
 
Transformation xmltoobjectesb
Transformation xmltoobjectesbTransformation xmltoobjectesb
Transformation xmltoobjectesb
 
Transformation xmltoobjectesb
Transformation xmltoobjectesbTransformation xmltoobjectesb
Transformation xmltoobjectesb
 
Transformation xmltoobjectesb
Transformation xmltoobjectesbTransformation xmltoobjectesb
Transformation xmltoobjectesb
 
Transformation xmltoobjectesb
Transformation xmltoobjectesbTransformation xmltoobjectesb
Transformation xmltoobjectesb
 
Transform json to json
Transform json to jsonTransform json to json
Transform json to json
 
Json
JsonJson
Json
 
Converting with custom transformer
Converting with custom transformerConverting with custom transformer
Converting with custom transformer
 
Transforming with custom transformer in mule
Transforming with custom transformer in muleTransforming with custom transformer in mule
Transforming with custom transformer in mule
 
Converting with custom transformer
Converting with custom transformerConverting with custom transformer
Converting with custom transformer
 
Converting with custom transformer
Converting with custom transformer Converting with custom transformer
Converting with custom transformer
 
Converting with custom transforme
Converting with custom transformeConverting with custom transforme
Converting with custom transforme
 

More from Antonio Pellegrino

Example esb file-to-string flow
Example esb file-to-string flowExample esb file-to-string flow
Example esb file-to-string flow
Antonio Pellegrino
 
Example esb flow
Example esb flowExample esb flow
Example esb flow
Antonio Pellegrino
 
Example esb flow
Example esb flowExample esb flow
Example esb flow
Antonio Pellegrino
 
Esb first http flow
Esb first http flowEsb first http flow
Esb first http flow
Antonio Pellegrino
 
Http component
Http componentHttp component
Http component
Antonio Pellegrino
 
Configurare https mule
Configurare https muleConfigurare https mule
Configurare https mule
Antonio Pellegrino
 
Configurare http mule
Configurare http muleConfigurare http mule
Configurare http mule
Antonio Pellegrino
 
Rest fullservices
Rest fullservicesRest fullservices
Rest fullservices
Antonio Pellegrino
 
Transformation csvtoxml
Transformation csvtoxmlTransformation csvtoxml
Transformation csvtoxml
Antonio Pellegrino
 
Transformation jsontoxmlesb
Transformation jsontoxmlesbTransformation jsontoxmlesb
Transformation jsontoxmlesb
Antonio Pellegrino
 
Json to json transformation in mule
Json to json transformation in muleJson to json transformation in mule
Json to json transformation in mule
Antonio Pellegrino
 
Create web services jax - ws3
Create web services jax - ws3Create web services jax - ws3
Create web services jax - ws3
Antonio Pellegrino
 
Create web services jax - ws2
Create web services jax - ws2Create web services jax - ws2
Create web services jax - ws2
Antonio Pellegrino
 
Create web services jax - ws1
Create web services jax - ws1Create web services jax - ws1
Create web services jax - ws1
Antonio Pellegrino
 

More from Antonio Pellegrino (14)

Example esb file-to-string flow
Example esb file-to-string flowExample esb file-to-string flow
Example esb file-to-string flow
 
Example esb flow
Example esb flowExample esb flow
Example esb flow
 
Example esb flow
Example esb flowExample esb flow
Example esb flow
 
Esb first http flow
Esb first http flowEsb first http flow
Esb first http flow
 
Http component
Http componentHttp component
Http component
 
Configurare https mule
Configurare https muleConfigurare https mule
Configurare https mule
 
Configurare http mule
Configurare http muleConfigurare http mule
Configurare http mule
 
Rest fullservices
Rest fullservicesRest fullservices
Rest fullservices
 
Transformation csvtoxml
Transformation csvtoxmlTransformation csvtoxml
Transformation csvtoxml
 
Transformation jsontoxmlesb
Transformation jsontoxmlesbTransformation jsontoxmlesb
Transformation jsontoxmlesb
 
Json to json transformation in mule
Json to json transformation in muleJson to json transformation in mule
Json to json transformation in mule
 
Create web services jax - ws3
Create web services jax - ws3Create web services jax - ws3
Create web services jax - ws3
 
Create web services jax - ws2
Create web services jax - ws2Create web services jax - ws2
Create web services jax - ws2
 
Create web services jax - ws1
Create web services jax - ws1Create web services jax - ws1
Create web services jax - ws1
 

Recently uploaded

Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
SUTEJAS
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
fxintegritypublishin
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
ydteq
 
Steel & Timber Design according to British Standard
Steel & Timber Design according to British StandardSteel & Timber Design according to British Standard
Steel & Timber Design according to British Standard
AkolbilaEmmanuel1
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Christina Lin
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Sreedhar Chowdam
 
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdfTutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
aqil azizi
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
Kamal Acharya
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
AJAYKUMARPUND1
 
DfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributionsDfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributions
gestioneergodomus
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
zwunae
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
gerogepatton
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
Unbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptxUnbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptx
ChristineTorrepenida1
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
Osamah Alsalih
 
Technical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prismsTechnical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prisms
heavyhaig
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
Kamal Acharya
 
Water billing management system project report.pdf
Water billing management system project report.pdfWater billing management system project report.pdf
Water billing management system project report.pdf
Kamal Acharya
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
Amil Baba Dawood bangali
 

Recently uploaded (20)

Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
 
Steel & Timber Design according to British Standard
Steel & Timber Design according to British StandardSteel & Timber Design according to British Standard
Steel & Timber Design according to British Standard
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
 
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdfTutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
 
DfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributionsDfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributions
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
Unbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptxUnbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptx
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
 
Technical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prismsTechnical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prisms
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
 
Water billing management system project report.pdf
Water billing management system project report.pdfWater billing management system project report.pdf
Water billing management system project report.pdf
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
 

Transformation jsontojsonesb

  • 1. JSON to JSON transformation in Mule
  • 2. We often deals with JSON payloads in our application on a large scale, specially whenever we are exposing or consuming a REST API. One of the common scenario we get is to modify or transform the input JSON payload to another JSON format and produce it as an output.
  • 3. if we consider the following { "name": “Maurizio Rorato", "id": 37 } This is a simple JSON payload taken as an example, which contains only 2 elements, that is name and id.
  • 4. So, if this JSON payload is coming into our application as an input and we require to transform/modify the payload into another JSON format and produce it as an output, something like the following { "name": "John Rosso", "id": 37, "designation": "Director" }
  • 5. Where you can see the modified JSON has a new element designation as a third element. The challenge here is to modify the existing input JSON payload and to design an output JSON payload from it, which will contain this additional element in it with the same format. So, the question is, how can be the input JSON format can be modified or transformed in another JSON format that we require, in a Mule application ??
  • 6. The answer is Mule has a rich set of transformers and offers different options to transform form one format of payload into another. Mule also offers a powerful component called Datamapper, which is limited to Mule enterprise edition, and that can perform all these requirement in easy way.
  • 7. But here for Mule community edition, we will choose a simplest way of doing it. We will be using Expression Transformer for doing this. Here is the following Mule flow, where we can transform the JSON input into another JSON format. So, you can transform from one JSON to another dynamically using Expression transformer in the following flow.
  • 8. <flow name="DynamicJSONFlow1" doc:name="DynamicJSONFlow1"> <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8085" path="test" doc:name="HTTP"/> <json:json-to-object-transformer returnClass="java.lang.Object" doc:name="JSON to Object"/> <set-variable variableName="name" value="#[message.payload.name]" doc:name="Variable"/> <set-variable variableName="id" value="#[message.payload.id]" doc:name="Variable"/> <expression-transformer