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>
Json to json transformation in mule
Ad

More Related Content

What's hot (12)

Dataweave
DataweaveDataweave
Dataweave
Bhoopal Kante
 
Parameters as a part of body
Parameters as a part of bodyParameters as a part of body
Parameters as a part of body
Anirban Sen Chowdhary
 
Xslt with mule
Xslt with muleXslt with mule
Xslt with mule
Son Nguyen
 
Mule esb How to use Jackson in Object to Json converter
Mule esb How to use Jackson in Object to Json converterMule esb How to use Jackson in Object to Json converter
Mule esb How to use Jackson in Object to Json converter
Raffaela Vitiello
 
Mule esb data weave multi input data
Mule esb data weave multi input dataMule esb data weave multi input data
Mule esb data weave multi input data
AnilKumar Etagowni
 
Mapping and listing with mule
Mapping and listing with muleMapping and listing with mule
Mapping and listing with mule
Anirban Sen Chowdhary
 
xslt in mule
xslt in mulexslt in mule
xslt in mule
Praneethchampion
 
Xslt in mule
Xslt in muleXslt in mule
Xslt in mule
Mohammed246
 
Mulesoft http connector
Mulesoft http connectorMulesoft http connector
Mulesoft http connector
kumar gaurav
 
Xml to xml transformation in mule
Xml to xml transformation in muleXml to xml transformation in mule
Xml to xml transformation in mule
Rajkattamuri
 
Mule with composite source
Mule with composite sourceMule with composite source
Mule with composite source
Anirban Sen Chowdhary
 
Mapping and listing with mule
Mapping and listing with muleMapping and listing with mule
Mapping and listing with mule
Praneethchampion
 
Xslt with mule
Xslt with muleXslt with mule
Xslt with mule
Son Nguyen
 
Mule esb How to use Jackson in Object to Json converter
Mule esb How to use Jackson in Object to Json converterMule esb How to use Jackson in Object to Json converter
Mule esb How to use Jackson in Object to Json converter
Raffaela Vitiello
 
Mule esb data weave multi input data
Mule esb data weave multi input dataMule esb data weave multi input data
Mule esb data weave multi input data
AnilKumar Etagowni
 
Mulesoft http connector
Mulesoft http connectorMulesoft http connector
Mulesoft http connector
kumar gaurav
 
Xml to xml transformation in mule
Xml to xml transformation in muleXml to xml transformation in mule
Xml to xml transformation in mule
Rajkattamuri
 
Mapping and listing with mule
Mapping and listing with muleMapping and listing with mule
Mapping and listing with mule
Praneethchampion
 

Viewers also liked (17)

Configurare https mule
Configurare https muleConfigurare https mule
Configurare https mule
Antonio Pellegrino
 
Mule esb - How to make CRUD operations to a MySql Database in 5 minutes
Mule esb - How to make CRUD operations to a MySql Database in 5 minutesMule esb - How to make CRUD operations to a MySql Database in 5 minutes
Mule esb - How to make CRUD operations to a MySql Database in 5 minutes
Gennaro Spagnoli
 
Vindhyancal college55
Vindhyancal college55Vindhyancal college55
Vindhyancal college55
Deepak Kesharwani
 
Today power
Today powerToday power
Today power
Eman al-zawwad
 
ìNdice
ìNdiceìNdice
ìNdice
Christian Poaquiza
 
La ley sopa
La ley sopaLa ley sopa
La ley sopa
georginet
 
Reference University of London
Reference University of LondonReference University of London
Reference University of London
Katya Davis
 
My Story at Oakland Univeristy
My Story at Oakland UniveristyMy Story at Oakland Univeristy
My Story at Oakland Univeristy
Eman al-zawwad
 
Mukesh resume
Mukesh resumeMukesh resume
Mukesh resume
MUKESH KUMAR
 
Ddf
DdfDdf
Ddf
JAN Carter
 
Component bindings in mule
Component bindings in muleComponent bindings in mule
Component bindings in mule
Sindhu VL
 
Mule esb messages Different type of mule messages
Mule esb messages Different type of mule messagesMule esb messages Different type of mule messages
Mule esb messages Different type of mule messages
veena naresh
 
Mule debugging
Mule   debuggingMule   debugging
Mule debugging
Sindhu VL
 
Mule esb entry pointresolver
Mule esb entry pointresolverMule esb entry pointresolver
Mule esb entry pointresolver
veena naresh
 
Mule anypointconnector dev kit
Mule anypointconnector dev kitMule anypointconnector dev kit
Mule anypointconnector dev kit
himajareddys
 
Mule functional testing
Mule functional testingMule functional testing
Mule functional testing
Naresh Naidu
 
Mule anypointenterprisesecurity
Mule anypointenterprisesecurityMule anypointenterprisesecurity
Mule anypointenterprisesecurity
himajareddys
 
Mule esb - How to make CRUD operations to a MySql Database in 5 minutes
Mule esb - How to make CRUD operations to a MySql Database in 5 minutesMule esb - How to make CRUD operations to a MySql Database in 5 minutes
Mule esb - How to make CRUD operations to a MySql Database in 5 minutes
Gennaro Spagnoli
 
Reference University of London
Reference University of LondonReference University of London
Reference University of London
Katya Davis
 
My Story at Oakland Univeristy
My Story at Oakland UniveristyMy Story at Oakland Univeristy
My Story at Oakland Univeristy
Eman al-zawwad
 
Component bindings in mule
Component bindings in muleComponent bindings in mule
Component bindings in mule
Sindhu VL
 
Mule esb messages Different type of mule messages
Mule esb messages Different type of mule messagesMule esb messages Different type of mule messages
Mule esb messages Different type of mule messages
veena naresh
 
Mule debugging
Mule   debuggingMule   debugging
Mule debugging
Sindhu VL
 
Mule esb entry pointresolver
Mule esb entry pointresolverMule esb entry pointresolver
Mule esb entry pointresolver
veena naresh
 
Mule anypointconnector dev kit
Mule anypointconnector dev kitMule anypointconnector dev kit
Mule anypointconnector dev kit
himajareddys
 
Mule functional testing
Mule functional testingMule functional testing
Mule functional testing
Naresh Naidu
 
Mule anypointenterprisesecurity
Mule anypointenterprisesecurityMule anypointenterprisesecurity
Mule anypointenterprisesecurity
himajareddys
 
Ad

Similar to Json to json transformation in mule (20)

Json to json transformation in mule
Json to json transformation in muleJson to json transformation in mule
Json to json transformation in mule
Davide Rapacciuolo
 
Transformation jsontojsonesb
Transformation jsontojsonesbTransformation jsontojsonesb
Transformation jsontojsonesb
Davide Rapacciuolo
 
Json to json esb transformation
Json to json esb transformationJson to json esb transformation
Json to json esb transformation
Domenico Schiavone
 
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
Mohammed625
 
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
Germano Barba
 
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
 
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 transforme
Converting with custom transformeConverting with custom transforme
Converting with custom transforme
Khasim Saheb
 
Converting with custom transformer
Converting with custom transformer Converting with custom transformer
Converting with custom transformer
mdfkhan625
 
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
 
Json to json transformation in mule
Json to json transformation in muleJson to json transformation in mule
Json to json transformation in mule
Davide Rapacciuolo
 
Json to json esb transformation
Json to json esb transformationJson to json esb transformation
Json to json esb transformation
Domenico Schiavone
 
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
Mohammed625
 
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 to xml transformation in mule
Xml to xml transformation in muleXml to xml transformation in mule
Xml to xml transformation in mule
Germano Barba
 
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
 
Transformation xmltoobjectesb
Transformation xmltoobjectesbTransformation xmltoobjectesb
Transformation xmltoobjectesb
Germano Barba
 
Transform json to json
Transform json to jsonTransform json to json
Transform json to json
Son Nguyen
 
Converting with custom transforme
Converting with custom transformeConverting with custom transforme
Converting with custom transforme
Khasim Saheb
 
Converting with custom transformer
Converting with custom transformer Converting with custom transformer
Converting with custom transformer
mdfkhan625
 
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
 
Ad

More from Antonio Pellegrino (13)

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 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
 
Transformation jsontojsonesb
Transformation jsontojsonesbTransformation jsontojsonesb
Transformation jsontojsonesb
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
 

Recently uploaded (20)

Artificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptxArtificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptx
aditichinar
 
IntroSlides-April-BuildWithAI-VertexAI.pdf
IntroSlides-April-BuildWithAI-VertexAI.pdfIntroSlides-April-BuildWithAI-VertexAI.pdf
IntroSlides-April-BuildWithAI-VertexAI.pdf
Luiz Carneiro
 
Fort night presentation new0903 pdf.pdf.
Fort night presentation new0903 pdf.pdf.Fort night presentation new0903 pdf.pdf.
Fort night presentation new0903 pdf.pdf.
anuragmk56
 
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G..."Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
Infopitaara
 
Compiler Design_Lexical Analysis phase.pptx
Compiler Design_Lexical Analysis phase.pptxCompiler Design_Lexical Analysis phase.pptx
Compiler Design_Lexical Analysis phase.pptx
RushaliDeshmukh2
 
Metal alkyne complexes.pptx in chemistry
Metal alkyne complexes.pptx in chemistryMetal alkyne complexes.pptx in chemistry
Metal alkyne complexes.pptx in chemistry
mee23nu
 
211421893-M-Tech-CIVIL-Structural-Engineering-pdf.pdf
211421893-M-Tech-CIVIL-Structural-Engineering-pdf.pdf211421893-M-Tech-CIVIL-Structural-Engineering-pdf.pdf
211421893-M-Tech-CIVIL-Structural-Engineering-pdf.pdf
inmishra17121973
 
Introduction to Zoomlion Earthmoving.pptx
Introduction to Zoomlion Earthmoving.pptxIntroduction to Zoomlion Earthmoving.pptx
Introduction to Zoomlion Earthmoving.pptx
AS1920
 
railway wheels, descaling after reheating and before forging
railway wheels, descaling after reheating and before forgingrailway wheels, descaling after reheating and before forging
railway wheels, descaling after reheating and before forging
Javad Kadkhodapour
 
International Journal of Distributed and Parallel systems (IJDPS)
International Journal of Distributed and Parallel systems (IJDPS)International Journal of Distributed and Parallel systems (IJDPS)
International Journal of Distributed and Parallel systems (IJDPS)
samueljackson3773
 
DT REPORT by Tech titan GROUP to introduce the subject design Thinking
DT REPORT by Tech titan GROUP to introduce the subject design ThinkingDT REPORT by Tech titan GROUP to introduce the subject design Thinking
DT REPORT by Tech titan GROUP to introduce the subject design Thinking
DhruvChotaliya2
 
Reagent dosing (Bredel) presentation.pptx
Reagent dosing (Bredel) presentation.pptxReagent dosing (Bredel) presentation.pptx
Reagent dosing (Bredel) presentation.pptx
AlejandroOdio
 
Smart_Storage_Systems_Production_Engineering.pptx
Smart_Storage_Systems_Production_Engineering.pptxSmart_Storage_Systems_Production_Engineering.pptx
Smart_Storage_Systems_Production_Engineering.pptx
rushikeshnavghare94
 
Data Structures_Introduction to algorithms.pptx
Data Structures_Introduction to algorithms.pptxData Structures_Introduction to algorithms.pptx
Data Structures_Introduction to algorithms.pptx
RushaliDeshmukh2
 
DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...
DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...
DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...
charlesdick1345
 
ELectronics Boards & Product Testing_Shiju.pdf
ELectronics Boards & Product Testing_Shiju.pdfELectronics Boards & Product Testing_Shiju.pdf
ELectronics Boards & Product Testing_Shiju.pdf
Shiju Jacob
 
fluke dealers in bangalore..............
fluke dealers in bangalore..............fluke dealers in bangalore..............
fluke dealers in bangalore..............
Haresh Vaswani
 
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITYADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ijscai
 
some basics electrical and electronics knowledge
some basics electrical and electronics knowledgesome basics electrical and electronics knowledge
some basics electrical and electronics knowledge
nguyentrungdo88
 
new ppt artificial intelligence historyyy
new ppt artificial intelligence historyyynew ppt artificial intelligence historyyy
new ppt artificial intelligence historyyy
PianoPianist
 
Artificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptxArtificial Intelligence (AI) basics.pptx
Artificial Intelligence (AI) basics.pptx
aditichinar
 
IntroSlides-April-BuildWithAI-VertexAI.pdf
IntroSlides-April-BuildWithAI-VertexAI.pdfIntroSlides-April-BuildWithAI-VertexAI.pdf
IntroSlides-April-BuildWithAI-VertexAI.pdf
Luiz Carneiro
 
Fort night presentation new0903 pdf.pdf.
Fort night presentation new0903 pdf.pdf.Fort night presentation new0903 pdf.pdf.
Fort night presentation new0903 pdf.pdf.
anuragmk56
 
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G..."Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
Infopitaara
 
Compiler Design_Lexical Analysis phase.pptx
Compiler Design_Lexical Analysis phase.pptxCompiler Design_Lexical Analysis phase.pptx
Compiler Design_Lexical Analysis phase.pptx
RushaliDeshmukh2
 
Metal alkyne complexes.pptx in chemistry
Metal alkyne complexes.pptx in chemistryMetal alkyne complexes.pptx in chemistry
Metal alkyne complexes.pptx in chemistry
mee23nu
 
211421893-M-Tech-CIVIL-Structural-Engineering-pdf.pdf
211421893-M-Tech-CIVIL-Structural-Engineering-pdf.pdf211421893-M-Tech-CIVIL-Structural-Engineering-pdf.pdf
211421893-M-Tech-CIVIL-Structural-Engineering-pdf.pdf
inmishra17121973
 
Introduction to Zoomlion Earthmoving.pptx
Introduction to Zoomlion Earthmoving.pptxIntroduction to Zoomlion Earthmoving.pptx
Introduction to Zoomlion Earthmoving.pptx
AS1920
 
railway wheels, descaling after reheating and before forging
railway wheels, descaling after reheating and before forgingrailway wheels, descaling after reheating and before forging
railway wheels, descaling after reheating and before forging
Javad Kadkhodapour
 
International Journal of Distributed and Parallel systems (IJDPS)
International Journal of Distributed and Parallel systems (IJDPS)International Journal of Distributed and Parallel systems (IJDPS)
International Journal of Distributed and Parallel systems (IJDPS)
samueljackson3773
 
DT REPORT by Tech titan GROUP to introduce the subject design Thinking
DT REPORT by Tech titan GROUP to introduce the subject design ThinkingDT REPORT by Tech titan GROUP to introduce the subject design Thinking
DT REPORT by Tech titan GROUP to introduce the subject design Thinking
DhruvChotaliya2
 
Reagent dosing (Bredel) presentation.pptx
Reagent dosing (Bredel) presentation.pptxReagent dosing (Bredel) presentation.pptx
Reagent dosing (Bredel) presentation.pptx
AlejandroOdio
 
Smart_Storage_Systems_Production_Engineering.pptx
Smart_Storage_Systems_Production_Engineering.pptxSmart_Storage_Systems_Production_Engineering.pptx
Smart_Storage_Systems_Production_Engineering.pptx
rushikeshnavghare94
 
Data Structures_Introduction to algorithms.pptx
Data Structures_Introduction to algorithms.pptxData Structures_Introduction to algorithms.pptx
Data Structures_Introduction to algorithms.pptx
RushaliDeshmukh2
 
DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...
DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...
DATA-DRIVEN SHOULDER INVERSE KINEMATICS YoungBeom Kim1 , Byung-Ha Park1 , Kwa...
charlesdick1345
 
ELectronics Boards & Product Testing_Shiju.pdf
ELectronics Boards & Product Testing_Shiju.pdfELectronics Boards & Product Testing_Shiju.pdf
ELectronics Boards & Product Testing_Shiju.pdf
Shiju Jacob
 
fluke dealers in bangalore..............
fluke dealers in bangalore..............fluke dealers in bangalore..............
fluke dealers in bangalore..............
Haresh Vaswani
 
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITYADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ijscai
 
some basics electrical and electronics knowledge
some basics electrical and electronics knowledgesome basics electrical and electronics knowledge
some basics electrical and electronics knowledge
nguyentrungdo88
 
new ppt artificial intelligence historyyy
new ppt artificial intelligence historyyynew ppt artificial intelligence historyyy
new ppt artificial intelligence historyyy
PianoPianist
 

Json to json transformation in mule

  • 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