SlideShare ist ein Scribd-Unternehmen logo
1 von 11
TRANSFORM JSON TO JSON
IF WE TAKE AN SIMPLE EXAMPLE, LET US
CONSIDER WE HAVE THE FOLLOWING JSON
PAYLOAD AS AN INPUT FOR OUR APPLICATION :-
{ "NAME": "ANIRBAN SEN CHOWDHARY", "ID": 37 }
.
AS YOU CAN SEE HERE, 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": "ANIRBAN SEN CHOWDHARY", "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 USING EXPRESSION TRANSFORMER :
THE INPUT JSON IN THE FLOW, IT IS EXTRACTING ALL THE
ELEMENT ( NAME AND ID ) FROM THE JSON AND STORING IT IN
VARIABLE.
AFTER THAT, THE EXPRESSION TRANSFORMER COMES INTO THE
PICTURE, WHICH IS RESPONSIBLE IN DESIGNING OUR OUTPUT
JSON PAYLOAD AND ADDING THE ELEMENT DESIGNATION IN IT.
THE GRAPHICAL REPRESENTATION OF THIS FLOW WILL BE AS
FOLLOWS :-
NOW, WE ARE DONE WITH OUR CODING AND WILL DEPLOY
OUR APPLICATION AND TEST IT.
ONCE DEPLOYED ON MULE SERVER, WE CAN TEST OUR
APPLICATION USING RESTCLIENT OR ANY OTHER CLIENT
YOU WISH.
ONCE WE CLICK THE SEND BUTTON WE WILL GET THE
FOLLOWING RESPONSE IN OUR CLIENT FROM OUR MULE
FLOW :-
PAYLOAD INTO ANOTHER JSON FORMAT IS EXTREMELY
EASY IN MULE USING THE EXPRESSION TRANSFORMER.
YOU CAN DESIGN YOUR OUTPUT JSON PAYLOAD IN ANY
FORMAT YOU REQUIRE USING THIS COMPONENT EASILY IN
YOUR MULE FLOW AND CAN CREATE YOUR DYNAMIC JSON
PAYLOAD EASILY !!!
THAT’S ALL !!! I’VE HOPEFULLY BEEN CLEAR ENOUGH IN
DISPLAYING THE IMPLEMENTATION OF EXPRESSION
TRANSFORMER IN DESIGNING AND MODIFYING YOUR JSON
PAYLOAD WHICH YOU CAN PRODUCE AS AN OUTPUT FROM
YOUR API OR APPLICATION.
I HOPE YOU LIKED THIS !!!
Hope you enjoyed the simple yet an amazing trick in Mule
You can also find this post here :- http://bushorn.com/json-to-json-
transformation-in-mule/

Weitere ähnliche Inhalte

Andere mochten auch

PENCEGAHAN KEMALANGAN KENDERAAN BERMOTOR
PENCEGAHAN KEMALANGAN KENDERAAN BERMOTORPENCEGAHAN KEMALANGAN KENDERAAN BERMOTOR
PENCEGAHAN KEMALANGAN KENDERAAN BERMOTORMuhammad Nasrullah
 
Alerte a la pollution aux particules fines PM10 pour les Hautes Pyrenees pour...
Alerte a la pollution aux particules fines PM10 pour les Hautes Pyrenees pour...Alerte a la pollution aux particules fines PM10 pour les Hautes Pyrenees pour...
Alerte a la pollution aux particules fines PM10 pour les Hautes Pyrenees pour...Philippe Villette
 
Arh1000 sp2017 syllabus
Arh1000 sp2017 syllabusArh1000 sp2017 syllabus
Arh1000 sp2017 syllabusProfWillAdams
 
Full Study: Performance Reviews Get a Failing Grade
Full Study: Performance Reviews Get a Failing GradeFull Study: Performance Reviews Get a Failing Grade
Full Study: Performance Reviews Get a Failing GradeAdobe
 
Campaña de las manos
Campaña de las manosCampaña de las manos
Campaña de las manosandiscc
 
Essay "Das letzte Kapitel?"
Essay "Das letzte Kapitel?"Essay "Das letzte Kapitel?"
Essay "Das letzte Kapitel?"Fiona Pröll
 

Andere mochten auch (7)

Distribution strategy
Distribution strategyDistribution strategy
Distribution strategy
 
PENCEGAHAN KEMALANGAN KENDERAAN BERMOTOR
PENCEGAHAN KEMALANGAN KENDERAAN BERMOTORPENCEGAHAN KEMALANGAN KENDERAAN BERMOTOR
PENCEGAHAN KEMALANGAN KENDERAAN BERMOTOR
 
Alerte a la pollution aux particules fines PM10 pour les Hautes Pyrenees pour...
Alerte a la pollution aux particules fines PM10 pour les Hautes Pyrenees pour...Alerte a la pollution aux particules fines PM10 pour les Hautes Pyrenees pour...
Alerte a la pollution aux particules fines PM10 pour les Hautes Pyrenees pour...
 
Arh1000 sp2017 syllabus
Arh1000 sp2017 syllabusArh1000 sp2017 syllabus
Arh1000 sp2017 syllabus
 
Full Study: Performance Reviews Get a Failing Grade
Full Study: Performance Reviews Get a Failing GradeFull Study: Performance Reviews Get a Failing Grade
Full Study: Performance Reviews Get a Failing Grade
 
Campaña de las manos
Campaña de las manosCampaña de las manos
Campaña de las manos
 
Essay "Das letzte Kapitel?"
Essay "Das letzte Kapitel?"Essay "Das letzte Kapitel?"
Essay "Das letzte Kapitel?"
 

Ähnlich wie Transform json to json

Json to json esb transformation
Json to json esb transformationJson to json esb transformation
Json to json esb transformationDomenico Schiavone
 
Json to json transformation in mule
Json to json transformation in muleJson to json transformation in mule
Json to json transformation in muleDavide Rapacciuolo
 
Transformation jsontojsonesb
Transformation jsontojsonesbTransformation jsontojsonesb
Transformation jsontojsonesbGermano Barba
 
Json to json transformation in mule
Json to json transformation in muleJson to json transformation in mule
Json to json transformation in muleAntonio Pellegrino
 
Xml to xml transformation
Xml to xml transformationXml to xml transformation
Xml to xml transformationSon Nguyen
 
Creating dynamic json
Creating dynamic json Creating dynamic json
Creating dynamic json mdfkhan625
 
Creating dynamic json
Creating dynamic jsonCreating dynamic json
Creating dynamic jsonMohammed246
 
Creating dynamic json
Creating dynamic json Creating dynamic json
Creating dynamic json javeed_mhd
 
Creating dynamic json
Creating dynamic json Creating dynamic json
Creating dynamic json Mohammed625
 
Creating dynamic json
Creating dynamic jsonCreating dynamic json
Creating dynamic jsonHasan Syed
 
Creating dynamic json
Creating dynamic json Creating dynamic json
Creating dynamic json Khasim Saheb
 
Creating dynamic json in mule
Creating dynamic json in muleCreating dynamic json in mule
Creating dynamic json in mulePraneethchampion
 
Creating dynamic json in Mule
Creating dynamic json in MuleCreating dynamic json in Mule
Creating dynamic json in MuleF K
 
Create dynamic json using mule
Create dynamic json using muleCreate dynamic json using mule
Create dynamic json using muleSon Nguyen
 

Ähnlich wie Transform json to json (20)

Json to json esb transformation
Json to json esb transformationJson to json esb transformation
Json to json esb transformation
 
Json to json transformation in mule
Json to json transformation in muleJson to json transformation in mule
Json to json transformation in mule
 
Transformation jsontojsonesb
Transformation jsontojsonesbTransformation jsontojsonesb
Transformation jsontojsonesb
 
Transformation jsontojsonesb
Transformation jsontojsonesbTransformation jsontojsonesb
Transformation jsontojsonesb
 
Transformation jsontojsonesb
Transformation jsontojsonesbTransformation jsontojsonesb
Transformation jsontojsonesb
 
Json to json transformation in mule
Json to json transformation in muleJson to json transformation in mule
Json to json transformation in mule
 
Json
JsonJson
Json
 
Xml to xml transformation
Xml to xml transformationXml to xml transformation
Xml to xml transformation
 
Creating dynamic json
Creating dynamic jsonCreating dynamic json
Creating dynamic json
 
Creating dynamic json
Creating dynamic json Creating dynamic json
Creating dynamic json
 
Creating dynamic json
Creating dynamic jsonCreating 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
Creating dynamic json
 
Creating dynamic json
Creating dynamic jsonCreating dynamic json
Creating dynamic json
 
Creating dynamic json
Creating dynamic json Creating dynamic json
Creating dynamic json
 
Creating dynamic json in mule
Creating dynamic json in muleCreating dynamic json in mule
Creating dynamic json in mule
 
Creating dynamic json
Creating dynamic jsonCreating dynamic json
Creating dynamic json
 
Creating dynamic json
Creating dynamic jsonCreating dynamic json
Creating dynamic json
 
Creating dynamic json in Mule
Creating dynamic json in MuleCreating dynamic json in Mule
Creating dynamic json in Mule
 
Create dynamic json using mule
Create dynamic json using muleCreate dynamic json using mule
Create dynamic json using mule
 

Mehr von Son Nguyen

Wsdl connector introduction
Wsdl connector introductionWsdl connector introduction
Wsdl connector introductionSon Nguyen
 
Android intergrate with mule
Android intergrate with muleAndroid intergrate with mule
Android intergrate with muleSon Nguyen
 
Mule flow overview
Mule flow overviewMule flow overview
Mule flow overviewSon Nguyen
 
Mule flow and filter
Mule flow and filterMule flow and filter
Mule flow and filterSon Nguyen
 
Handle exceptions in mule
Handle exceptions in muleHandle exceptions in mule
Handle exceptions in muleSon Nguyen
 
Spring security integrate with mule
Spring security integrate with muleSpring security integrate with mule
Spring security integrate with muleSon Nguyen
 
Message processor in mule
Message processor in muleMessage processor in mule
Message processor in muleSon Nguyen
 
Expression language in mule
Expression language in muleExpression language in mule
Expression language in muleSon Nguyen
 
Mule with data weave
Mule with data weaveMule with data weave
Mule with data weaveSon Nguyen
 
Using spring scheduler mule
Using spring scheduler muleUsing spring scheduler mule
Using spring scheduler muleSon Nguyen
 
Composite source in bound and out-bound
Composite source in bound and out-boundComposite source in bound and out-bound
Composite source in bound and out-boundSon Nguyen
 
Batch job processing
Batch job processingBatch job processing
Batch job processingSon Nguyen
 
Using message enricher
Using message enricherUsing message enricher
Using message enricherSon Nguyen
 
Finance connectors with mule
Finance connectors with muleFinance connectors with mule
Finance connectors with muleSon Nguyen
 
Google drive connection
Google drive connectionGoogle drive connection
Google drive connectionSon Nguyen
 
Using properties in mule
Using properties in muleUsing properties in mule
Using properties in muleSon Nguyen
 
Mule integrate with microsoft
Mule integrate with microsoftMule integrate with microsoft
Mule integrate with microsoftSon Nguyen
 
Anypoint connectors
Anypoint connectorsAnypoint connectors
Anypoint connectorsSon Nguyen
 
Mule esb basic introduction
Mule esb basic introductionMule esb basic introduction
Mule esb basic introductionSon Nguyen
 

Mehr von Son Nguyen (20)

Wsdl connector introduction
Wsdl connector introductionWsdl connector introduction
Wsdl connector introduction
 
Android intergrate with mule
Android intergrate with muleAndroid intergrate with mule
Android intergrate with mule
 
Mule flow overview
Mule flow overviewMule flow overview
Mule flow overview
 
Mule flow and filter
Mule flow and filterMule flow and filter
Mule flow and filter
 
Handle exceptions in mule
Handle exceptions in muleHandle exceptions in mule
Handle exceptions in mule
 
Spring security integrate with mule
Spring security integrate with muleSpring security integrate with mule
Spring security integrate with mule
 
Message processor in mule
Message processor in muleMessage processor in mule
Message processor in mule
 
Expression language in mule
Expression language in muleExpression language in mule
Expression language in mule
 
Mule with data weave
Mule with data weaveMule with data weave
Mule with data weave
 
Using spring scheduler mule
Using spring scheduler muleUsing spring scheduler mule
Using spring scheduler mule
 
Composite source in bound and out-bound
Composite source in bound and out-boundComposite source in bound and out-bound
Composite source in bound and out-bound
 
Batch job processing
Batch job processingBatch job processing
Batch job processing
 
Using message enricher
Using message enricherUsing message enricher
Using message enricher
 
Finance connectors with mule
Finance connectors with muleFinance connectors with mule
Finance connectors with mule
 
Google drive connection
Google drive connectionGoogle drive connection
Google drive connection
 
Using properties in mule
Using properties in muleUsing properties in mule
Using properties in mule
 
Mule integrate with microsoft
Mule integrate with microsoftMule integrate with microsoft
Mule integrate with microsoft
 
Jms queue
Jms queueJms queue
Jms queue
 
Anypoint connectors
Anypoint connectorsAnypoint connectors
Anypoint connectors
 
Mule esb basic introduction
Mule esb basic introductionMule esb basic introduction
Mule esb basic introduction
 

Kürzlich hochgeladen

Empowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintEmpowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintMahmoud Rabie
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdfPedro Manuel
 
Bird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemBird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemAsko Soukka
 
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...DianaGray10
 
Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )Brian Pichman
 
9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding TeamAdam Moalla
 
UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6DianaGray10
 
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDEADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDELiveplex
 
Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.YounusS2
 
Designing A Time bound resource download URL
Designing A Time bound resource download URLDesigning A Time bound resource download URL
Designing A Time bound resource download URLRuncy Oommen
 
20230202 - Introduction to tis-py
20230202 - Introduction to tis-py20230202 - Introduction to tis-py
20230202 - Introduction to tis-pyJamie (Taka) Wang
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Commit University
 
AI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity WebinarAI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity WebinarPrecisely
 
Linked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesLinked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesDavid Newbury
 
Videogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfVideogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfinfogdgmi
 
Introduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxIntroduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxMatsuo Lab
 
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration WorkflowsIgniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration WorkflowsSafe Software
 
VoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBXVoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBXTarek Kalaji
 
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostKubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostMatt Ray
 
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IES VE
 

Kürzlich hochgeladen (20)

Empowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintEmpowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership Blueprint
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdf
 
Bird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemBird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystem
 
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
 
Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )
 
9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team
 
UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6
 
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDEADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
 
Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.
 
Designing A Time bound resource download URL
Designing A Time bound resource download URLDesigning A Time bound resource download URL
Designing A Time bound resource download URL
 
20230202 - Introduction to tis-py
20230202 - Introduction to tis-py20230202 - Introduction to tis-py
20230202 - Introduction to tis-py
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)
 
AI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity WebinarAI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity Webinar
 
Linked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesLinked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond Ontologies
 
Videogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfVideogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdf
 
Introduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxIntroduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptx
 
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration WorkflowsIgniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
 
VoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBXVoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBX
 
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostKubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
 
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
 

Transform json to json

  • 2. IF WE TAKE AN SIMPLE EXAMPLE, LET US CONSIDER WE HAVE THE FOLLOWING JSON PAYLOAD AS AN INPUT FOR OUR APPLICATION :- { "NAME": "ANIRBAN SEN CHOWDHARY", "ID": 37 } .
  • 3. AS YOU CAN SEE HERE, 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": "ANIRBAN SEN CHOWDHARY", "ID": 37, "DESIGNATION": "DIRECTOR" }
  • 4. 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 ??
  • 5. 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.
  • 6. HERE IS THE FOLLOWING MULE FLOW, WHERE WE CAN TRANSFORM THE JSON INPUT INTO ANOTHER JSON FORMAT USING EXPRESSION TRANSFORMER :
  • 7. THE INPUT JSON IN THE FLOW, IT IS EXTRACTING ALL THE ELEMENT ( NAME AND ID ) FROM THE JSON AND STORING IT IN VARIABLE. AFTER THAT, THE EXPRESSION TRANSFORMER COMES INTO THE PICTURE, WHICH IS RESPONSIBLE IN DESIGNING OUR OUTPUT JSON PAYLOAD AND ADDING THE ELEMENT DESIGNATION IN IT. THE GRAPHICAL REPRESENTATION OF THIS FLOW WILL BE AS FOLLOWS :-
  • 8. NOW, WE ARE DONE WITH OUR CODING AND WILL DEPLOY OUR APPLICATION AND TEST IT. ONCE DEPLOYED ON MULE SERVER, WE CAN TEST OUR APPLICATION USING RESTCLIENT OR ANY OTHER CLIENT YOU WISH.
  • 9. ONCE WE CLICK THE SEND BUTTON WE WILL GET THE FOLLOWING RESPONSE IN OUR CLIENT FROM OUR MULE FLOW :-
  • 10. PAYLOAD INTO ANOTHER JSON FORMAT IS EXTREMELY EASY IN MULE USING THE EXPRESSION TRANSFORMER. YOU CAN DESIGN YOUR OUTPUT JSON PAYLOAD IN ANY FORMAT YOU REQUIRE USING THIS COMPONENT EASILY IN YOUR MULE FLOW AND CAN CREATE YOUR DYNAMIC JSON PAYLOAD EASILY !!! THAT’S ALL !!! I’VE HOPEFULLY BEEN CLEAR ENOUGH IN DISPLAYING THE IMPLEMENTATION OF EXPRESSION TRANSFORMER IN DESIGNING AND MODIFYING YOUR JSON PAYLOAD WHICH YOU CAN PRODUCE AS AN OUTPUT FROM YOUR API OR APPLICATION. I HOPE YOU LIKED THIS !!!
  • 11. Hope you enjoyed the simple yet an amazing trick in Mule You can also find this post here :- http://bushorn.com/json-to-json- transformation-in-mule/