SlideShare a Scribd company logo
1 of 10
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

September 18 English small - issuu
September 18 English small - issuuSeptember 18 English small - issuu
September 18 English small - issuuTuuli Saarela
 
Argentina composición de la población censo 2010
Argentina composición de la población censo 2010Argentina composición de la población censo 2010
Argentina composición de la población censo 2010Martin Alberto Belaustegui
 
Extraordinaire Dan Cretu's Creative Visual Art (Food art sculptures)
Extraordinaire Dan Cretu's Creative Visual Art (Food art sculptures) Extraordinaire Dan Cretu's Creative Visual Art (Food art sculptures)
Extraordinaire Dan Cretu's Creative Visual Art (Food art sculptures) Makala D.
 
Gold, gold, gold
Gold, gold, gold Gold, gold, gold
Gold, gold, gold Makala D.
 
Trabajo de informática de johnny echavez 10 a
Trabajo de informática de johnny echavez 10 aTrabajo de informática de johnny echavez 10 a
Trabajo de informática de johnny echavez 10 ajohnny19echavez
 
Plan estratégico de sonora music
Plan estratégico de sonora musicPlan estratégico de sonora music
Plan estratégico de sonora musicAgmv
 
Salesforce_Certified_Platform_Developer_I
Salesforce_Certified_Platform_Developer_ISalesforce_Certified_Platform_Developer_I
Salesforce_Certified_Platform_Developer_ISanjay Pandey
 
Martisor ...
Martisor ...Martisor ...
Martisor ...Makala D.
 
How are animals organised
How are animals organised How are animals organised
How are animals organised Fifthgrademiss
 
Mapa conceptual
Mapa conceptualMapa conceptual
Mapa conceptualOscar LS
 
Edwin Dando (Assurity Consulting)
Edwin Dando (Assurity Consulting)Edwin Dando (Assurity Consulting)
Edwin Dando (Assurity Consulting)AgileNZ Conference
 
Shane Hastie (SoftEd/Agile Alliance of Auckland)
Shane Hastie (SoftEd/Agile Alliance of Auckland)Shane Hastie (SoftEd/Agile Alliance of Auckland)
Shane Hastie (SoftEd/Agile Alliance of Auckland)AgileNZ Conference
 

Viewers also liked (20)

Plan entreno 2016
Plan entreno 2016Plan entreno 2016
Plan entreno 2016
 
Ciudadaníadigital
CiudadaníadigitalCiudadaníadigital
Ciudadaníadigital
 
September 18 English small - issuu
September 18 English small - issuuSeptember 18 English small - issuu
September 18 English small - issuu
 
Argentina composición de la población censo 2010
Argentina composición de la población censo 2010Argentina composición de la población censo 2010
Argentina composición de la población censo 2010
 
Extraordinaire Dan Cretu's Creative Visual Art (Food art sculptures)
Extraordinaire Dan Cretu's Creative Visual Art (Food art sculptures) Extraordinaire Dan Cretu's Creative Visual Art (Food art sculptures)
Extraordinaire Dan Cretu's Creative Visual Art (Food art sculptures)
 
Gold, gold, gold
Gold, gold, gold Gold, gold, gold
Gold, gold, gold
 
Trabajo de informática de johnny echavez 10 a
Trabajo de informática de johnny echavez 10 aTrabajo de informática de johnny echavez 10 a
Trabajo de informática de johnny echavez 10 a
 
Plan estratégico de sonora music
Plan estratégico de sonora musicPlan estratégico de sonora music
Plan estratégico de sonora music
 
Salesforce_Certified_Platform_Developer_I
Salesforce_Certified_Platform_Developer_ISalesforce_Certified_Platform_Developer_I
Salesforce_Certified_Platform_Developer_I
 
Martisor ...
Martisor ...Martisor ...
Martisor ...
 
Singapore smrt map
Singapore smrt mapSingapore smrt map
Singapore smrt map
 
How are animals organised
How are animals organised How are animals organised
How are animals organised
 
Mapa conceptual
Mapa conceptualMapa conceptual
Mapa conceptual
 
Unit 2: Nutricion
Unit 2: NutricionUnit 2: Nutricion
Unit 2: Nutricion
 
Edwin Dando (Assurity Consulting)
Edwin Dando (Assurity Consulting)Edwin Dando (Assurity Consulting)
Edwin Dando (Assurity Consulting)
 
Andrew Nimick (NZME)
Andrew Nimick (NZME)Andrew Nimick (NZME)
Andrew Nimick (NZME)
 
Shane Hastie (SoftEd/Agile Alliance of Auckland)
Shane Hastie (SoftEd/Agile Alliance of Auckland)Shane Hastie (SoftEd/Agile Alliance of Auckland)
Shane Hastie (SoftEd/Agile Alliance of Auckland)
 
Anthony Marter (Orion Health)
Anthony Marter (Orion Health)Anthony Marter (Orion Health)
Anthony Marter (Orion Health)
 
Kirstin Donaldson (Powershop)
Kirstin Donaldson (Powershop)Kirstin Donaldson (Powershop)
Kirstin Donaldson (Powershop)
 
Martin Cronje (MYOB)
Martin Cronje (MYOB)Martin Cronje (MYOB)
Martin Cronje (MYOB)
 

Similar to Transformation jsontojsonesb

Xml to xml transformation
Xml to xml transformationXml to xml transformation
Xml to xml transformationSon Nguyen
 
Xml to xml transformation in mule
Xml to xml transformation in muleXml to xml transformation in mule
Xml to xml transformation in mulemdfkhan625
 
Xml to xml transformation in mule
Xml to xml transformation in muleXml to xml transformation in mule
Xml to xml transformation in muleRajkattamuri
 
Xml to xml transformation in mule
Xml to xml transformation in muleXml to xml transformation in mule
Xml to xml transformation in mulejaveed_mhd
 
Xml to xml transformation in mule
Xml to xml transformation in muleXml to xml transformation in mule
Xml to xml transformation in muleMohammed625
 
Xml to xml transformation in mule
Xml to xml transformation in muleXml to xml transformation in mule
Xml to xml transformation in muleDavide Rapacciuolo
 
Mule xml transformation
Mule xml transformationMule xml transformation
Mule xml transformationD.Rajesh Kumar
 
Transformation xmltoobjectesb
Transformation xmltoobjectesbTransformation xmltoobjectesb
Transformation xmltoobjectesbGermano Barba
 
Transform json to json
Transform json to jsonTransform json to json
Transform json to jsonSon Nguyen
 
Converting with custom transformer
Converting with custom transformerConverting with custom transformer
Converting with custom transformerjaveed_mhd
 
Converting with custom transformer
Converting with custom transformerConverting with custom transformer
Converting with custom transformerMohammed246
 
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 transformeKhasim Saheb
 
Converting with custom transformer
Converting with custom transformerConverting with custom transformer
Converting with custom transformerF K
 

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
 
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
 
Converting with custom transformer
Converting with custom transformerConverting with custom transformer
Converting with custom transformer
 

More from Germano Barba

Transformation csvtoxml
Transformation csvtoxmlTransformation csvtoxml
Transformation csvtoxmlGermano Barba
 
Transformation jsontoxmlesb
Transformation jsontoxmlesbTransformation jsontoxmlesb
Transformation jsontoxmlesbGermano Barba
 
Mule esb first http connector
Mule esb first http connectorMule esb first http connector
Mule esb first http connectorGermano Barba
 
Mule esb using file to string and logger component
Mule esb using file to string and logger componentMule esb using file to string and logger component
Mule esb using file to string and logger componentGermano Barba
 
Mule esb using file to string and logger component
Mule esb using file to string and logger componentMule esb using file to string and logger component
Mule esb using file to string and logger componentGermano Barba
 
Mule esb add logger to existing flow
Mule esb add logger to existing flowMule esb add logger to existing flow
Mule esb add logger to existing flowGermano Barba
 
Mule esb first http connector
Mule esb first http connectorMule esb first http connector
Mule esb first http connectorGermano Barba
 

More from Germano Barba (13)

Mule esb lesson 3
Mule esb   lesson 3Mule esb   lesson 3
Mule esb lesson 3
 
Mule esb lesson 2
Mule esb   lesson 2Mule esb   lesson 2
Mule esb lesson 2
 
Mule esb lesson 1
Mule esb   lesson 1Mule esb   lesson 1
Mule esb lesson 1
 
Rest fullservices
Rest fullservicesRest fullservices
Rest fullservices
 
Transformation csvtoxml
Transformation csvtoxmlTransformation csvtoxml
Transformation csvtoxml
 
Transformation jsontoxmlesb
Transformation jsontoxmlesbTransformation jsontoxmlesb
Transformation jsontoxmlesb
 
Mule esb first http connector
Mule esb first http connectorMule esb first http connector
Mule esb first http connector
 
Mule esb using file to string and logger component
Mule esb using file to string and logger componentMule esb using file to string and logger component
Mule esb using file to string and logger component
 
Mule esb using file to string and logger component
Mule esb using file to string and logger componentMule esb using file to string and logger component
Mule esb using file to string and logger component
 
Mule hppt java
Mule hppt javaMule hppt java
Mule hppt java
 
Mule io flow
Mule io flowMule io flow
Mule io flow
 
Mule esb add logger to existing flow
Mule esb add logger to existing flowMule esb add logger to existing flow
Mule esb add logger to existing flow
 
Mule esb first http connector
Mule esb first http connectorMule esb first http connector
Mule esb first http connector
 

Recently uploaded

Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 

Recently uploaded (20)

Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 

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