SlideShare une entreprise Scribd logo
1  sur  22
Télécharger pour lire hors ligne
WSO2 API Manager Community Call
CSV and JSON transformation in MI 4.0.0
September 29th, 2021
Hello!
Dilan Tharaka
Senior Software Engineer
dilanth@wso2.com
Agenda
● Overview
● CSV Connector
● FreeMarker templates in Payload Factory mediator
● Demonstrations
What we will be covering today
4
Overview
Existing Methods to Tansformation
6
● Data Mapper
● PayloadFactory
● Script Mediator
● XSLT Mediator
● Class Mediator
CSV Module
8
CSV Module
Supporting Transformations in CSV Module
9
● CSV to CSV transformation
● CSV to JSON transformation
● CSV to XML transformation
● JSON to CSV transformation
● XML to CSV transformation
CSV Module Demo
FreeMarker Templates in
PayloadFactory
12
Apache FreeMarker
(https://freemarker.apache.org/images/overview.png)
● Free java-based templating engine
● Generated output based of the template and the data model
● Powerful template language: Conditional blocks, iterations, assignments, string
and arithmetic operations and formatting, macros and functions
Root Variables
13
● payload
● args
● ctx
● axis2
● trp
PayloadFactory Demo
JSON to XML
15
{
"first_name": "John",
"last_name": "Deo",
"age": 35,
"location": {
"state": {
"
code": "NY",
"
name": "New York"
},
"city": "Manhattan"
}
}
<user>
<Name>John Deo</Name>
<Age>35</Age>
<Address>Manhattan, NY</
Address>
</user>
<user>
<Name>${payload.first_name} ${payload.last_name}</
Name>
<Age>${payload.age}</
Age>
<Address>${payload.location.city}, ${payload.location.state.code}</
Address>
</user>
Input Output
Template
XML to JSON
16
<user>
<first_name >John</first_name >
<last_name>Deo</last_name>
<age>35</age>
<location>
<state code="NY">New York</ state>
<city>Manhattan</ city>
</location>
</user>
{
"Name": "John Doe" ,
"Age": 35,
"Address": "Manhattan, NY"
}
{
"Name": "${payload.user.first_name} ${payload.user.last_name}" ,
"Age": ${payload.user.age} ,
"Address": "${payload.user.location.city},${payload.user.location.state.@code}"
}
Input Output
Template
XML to CSV
17
<people>
<person>
<id>1</id>
<first_name>Veronika</first_name>
<last_name>Lacroux</last_name>
</person>
<person>
<id>2</id>
<first_name>Trescha</first_name>
<last_name>Campaigne</
last_name>
</person>
</people>
ID,First Name, Last Name
1,Veronika,Lacroux
2,Trescha,Campaigne
ID,First Name, Last Name
<#list payload.people.person as person>
${person.id},${person.first_name},${person.last_name}
</#list>
Input Output
Template
Bit more complex transformation
18
{
"custID": "cd5322",
"custName": "wso2",
"tier": "Gold",
"items": {
"item": [
{
"id": "0001",
"type": "donut",
"name": "Cake",
"ppu": 0.55,
"batters": {
"batter": [
{
"id": "1001",
"type": "Regular"
},
{
"id": "1002",
"type": "Chocolate"
}
]
}
},
{
"id": "0002",
"type": "donut",
"name": "Raised",
"ppu": 0.55,
"batters": {
"batter": [
{
"id": "1001",
"type": "Regular"
}
]
}
}
]
}
}
<cd5322 >
<cake>
<custName tier="Gold"> WSO2</custName >
<id>0001</id>
<type>donut </type>
<ppu>0.55</ppu>
<batter >
<id>1001</id>
<type>Regular </type>
</batter >
<batter >
<id>1002</id>
<type>Chocolate </type>
</batter >
</cake>
<cake>
<custName tier="Gold"> WSO2</custName >
<id>0002</id>
<type>donut </type>
<ppu>0.55</ppu>
<batter >
<id>1001</id>
<type>Regular </type>
</batter >
</cake>
</cd5322 >
Input Output
Bit more complex transformation - FreeMarker Template
19
<${payload.custID}>
<#list payload.items.item as item>
<cake>
<custName
tier="${payload.tier}">${payload.custName?upper_case}</custName>
<id>${item.id}</id>
<type>${item.type}</type>
<ppu>${item.ppu}</ppu>
<#list item.batters.batter as batter>
<batter>
<id>${batter.id}</id>
<type>${batter.type}</type>
</batter>
</#list>
</cake>
</#list>
</${payload.custID}>
Question Time!
● CSV Module
● Freemarker templates in PayloadFactory mediator
● Apache FreeMarker
Useful Links
21
wso2.com
Thanks!

Contenu connexe

Tendances

Tendances (20)

DevOps-as-a-Service: Towards Automating the Automation
DevOps-as-a-Service: Towards Automating the AutomationDevOps-as-a-Service: Towards Automating the Automation
DevOps-as-a-Service: Towards Automating the Automation
 
Introduction to microservices
Introduction to microservicesIntroduction to microservices
Introduction to microservices
 
Hands-On With Reactive Web Design
Hands-On With Reactive Web DesignHands-On With Reactive Web Design
Hands-On With Reactive Web Design
 
Introduction to the Web API
Introduction to the Web APIIntroduction to the Web API
Introduction to the Web API
 
Low code platform and Outsystems
Low code platform and Outsystems Low code platform and Outsystems
Low code platform and Outsystems
 
Microservice API Gateways with NGINX
Microservice API Gateways with NGINXMicroservice API Gateways with NGINX
Microservice API Gateways with NGINX
 
DevOps introduction
DevOps introductionDevOps introduction
DevOps introduction
 
Typescript Fundamentals
Typescript FundamentalsTypescript Fundamentals
Typescript Fundamentals
 
Implementing Domain Events with Kafka
Implementing Domain Events with KafkaImplementing Domain Events with Kafka
Implementing Domain Events with Kafka
 
Java Application Modernization Patterns and Stories from the IBM Garage
Java Application Modernization Patterns and Stories from the IBM GarageJava Application Modernization Patterns and Stories from the IBM Garage
Java Application Modernization Patterns and Stories from the IBM Garage
 
MLOps.pptx
MLOps.pptxMLOps.pptx
MLOps.pptx
 
DevOps Overview
DevOps OverviewDevOps Overview
DevOps Overview
 
Kubernetes Monitoring & Best Practices
Kubernetes Monitoring & Best PracticesKubernetes Monitoring & Best Practices
Kubernetes Monitoring & Best Practices
 
An Introduction To REST API
An Introduction To REST APIAn Introduction To REST API
An Introduction To REST API
 
Breaking down an Industrial IoT reference architecture.pptx
Breaking down an Industrial IoT reference architecture.pptxBreaking down an Industrial IoT reference architecture.pptx
Breaking down an Industrial IoT reference architecture.pptx
 
Introducing type script
Introducing type scriptIntroducing type script
Introducing type script
 
Why Microservice
Why Microservice Why Microservice
Why Microservice
 
GIS Into to Cloud Microsoft Azure
GIS  Into  to Cloud Microsoft Azure GIS  Into  to Cloud Microsoft Azure
GIS Into to Cloud Microsoft Azure
 
Kafka 101
Kafka 101Kafka 101
Kafka 101
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 

Similaire à CSV and JSON Transformation in WSO2 Micro Integrator 4.0 - WSO2 APIM Community Call (9/29/2021)

Application development using the wso2 developer studio
Application development using the wso2 developer studioApplication development using the wso2 developer studio
Application development using the wso2 developer studio
WSO2
 

Similaire à CSV and JSON Transformation in WSO2 Micro Integrator 4.0 - WSO2 APIM Community Call (9/29/2021) (20)

AMIS Oracle OpenWorld en Code One Review 2018 - Pillar 2: Custom Application ...
AMIS Oracle OpenWorld en Code One Review 2018 - Pillar 2: Custom Application ...AMIS Oracle OpenWorld en Code One Review 2018 - Pillar 2: Custom Application ...
AMIS Oracle OpenWorld en Code One Review 2018 - Pillar 2: Custom Application ...
 
AMIS Oracle OpenWorld & CodeOne Review - Pillar 2 - Custom Application Develo...
AMIS Oracle OpenWorld & CodeOne Review - Pillar 2 - Custom Application Develo...AMIS Oracle OpenWorld & CodeOne Review - Pillar 2 - Custom Application Develo...
AMIS Oracle OpenWorld & CodeOne Review - Pillar 2 - Custom Application Develo...
 
Apache Arrow: Open Source Standard Becomes an Enterprise Necessity
Apache Arrow: Open Source Standard Becomes an Enterprise NecessityApache Arrow: Open Source Standard Becomes an Enterprise Necessity
Apache Arrow: Open Source Standard Becomes an Enterprise Necessity
 
Primavera gateway SAP provider - Oracle Primavera P6 Collaborate 14
Primavera gateway SAP provider - Oracle Primavera P6 Collaborate 14Primavera gateway SAP provider - Oracle Primavera P6 Collaborate 14
Primavera gateway SAP provider - Oracle Primavera P6 Collaborate 14
 
RESTful Machine Learning with Flask and TensorFlow Serving - Carlo Mazzaferro
RESTful Machine Learning with Flask and TensorFlow Serving - Carlo MazzaferroRESTful Machine Learning with Flask and TensorFlow Serving - Carlo Mazzaferro
RESTful Machine Learning with Flask and TensorFlow Serving - Carlo Mazzaferro
 
Next.js with drupal, the good parts
Next.js with drupal, the good partsNext.js with drupal, the good parts
Next.js with drupal, the good parts
 
Google Cloud Dataflow
Google Cloud DataflowGoogle Cloud Dataflow
Google Cloud Dataflow
 
Mulesoft Online Training.pdf
Mulesoft Online Training.pdfMulesoft Online Training.pdf
Mulesoft Online Training.pdf
 
JChem Microservices
JChem MicroservicesJChem Microservices
JChem Microservices
 
Presentation on angular 5
Presentation on angular 5Presentation on angular 5
Presentation on angular 5
 
FICO Open Shift presentation
FICO Open Shift presentationFICO Open Shift presentation
FICO Open Shift presentation
 
Advanced Model Inferencing leveraging Kubeflow Serving, KNative and Istio
Advanced Model Inferencing leveraging Kubeflow Serving, KNative and IstioAdvanced Model Inferencing leveraging Kubeflow Serving, KNative and Istio
Advanced Model Inferencing leveraging Kubeflow Serving, KNative and Istio
 
Solving Enterprise Data Challenges with Apache Arrow
Solving Enterprise Data Challenges with Apache ArrowSolving Enterprise Data Challenges with Apache Arrow
Solving Enterprise Data Challenges with Apache Arrow
 
MLflow Model Serving - DAIS 2021
MLflow Model Serving - DAIS 2021MLflow Model Serving - DAIS 2021
MLflow Model Serving - DAIS 2021
 
MuleSoft Surat Virtual Meetup#6 - MuleSoft Project Template Using Maven Arche...
MuleSoft Surat Virtual Meetup#6 - MuleSoft Project Template Using Maven Arche...MuleSoft Surat Virtual Meetup#6 - MuleSoft Project Template Using Maven Arche...
MuleSoft Surat Virtual Meetup#6 - MuleSoft Project Template Using Maven Arche...
 
What's new in Portal and WCM 8.5
What's new in Portal and WCM 8.5What's new in Portal and WCM 8.5
What's new in Portal and WCM 8.5
 
Global Logic sMash Overview And Experiences
Global Logic   sMash  Overview And  ExperiencesGlobal Logic   sMash  Overview And  Experiences
Global Logic sMash Overview And Experiences
 
Confluent Platform 5.5 + Apache Kafka 2.5 => New Features (JSON Schema, Proto...
Confluent Platform 5.5 + Apache Kafka 2.5 => New Features (JSON Schema, Proto...Confluent Platform 5.5 + Apache Kafka 2.5 => New Features (JSON Schema, Proto...
Confluent Platform 5.5 + Apache Kafka 2.5 => New Features (JSON Schema, Proto...
 
Application development using the wso2 developer studio
Application development using the wso2 developer studioApplication development using the wso2 developer studio
Application development using the wso2 developer studio
 
Intro to .NET for Government Developers
Intro to .NET for Government DevelopersIntro to .NET for Government Developers
Intro to .NET for Government Developers
 

Plus de WSO2

Plus de WSO2 (20)

Driving Innovation: Scania's API Revolution with WSO2
Driving Innovation: Scania's API Revolution with WSO2Driving Innovation: Scania's API Revolution with WSO2
Driving Innovation: Scania's API Revolution with WSO2
 
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data PlatformLess Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
 
Modernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using BallerinaModernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using Ballerina
 
WSO2CON 2024 - Unlocking the Identity: Embracing CIAM 2.0 for a Competitive A...
WSO2CON 2024 - Unlocking the Identity: Embracing CIAM 2.0 for a Competitive A...WSO2CON 2024 - Unlocking the Identity: Embracing CIAM 2.0 for a Competitive A...
WSO2CON 2024 - Unlocking the Identity: Embracing CIAM 2.0 for a Competitive A...
 
WSO2CON 2024 Slides - Unlocking Value with AI
WSO2CON 2024 Slides - Unlocking Value with AIWSO2CON 2024 Slides - Unlocking Value with AI
WSO2CON 2024 Slides - Unlocking Value with AI
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Quantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation ComputingQuantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation Computing
 
WSO2CON 2024 - Elevating the Integration Game to the Cloud
WSO2CON 2024 - Elevating the Integration Game to the CloudWSO2CON 2024 - Elevating the Integration Game to the Cloud
WSO2CON 2024 - Elevating the Integration Game to the Cloud
 
WSO2CON 2024 - OSU & WSO2: A Decade Journey in Integration & Innovation
WSO2CON 2024 - OSU & WSO2: A Decade Journey in Integration & InnovationWSO2CON 2024 - OSU & WSO2: A Decade Journey in Integration & Innovation
WSO2CON 2024 - OSU & WSO2: A Decade Journey in Integration & Innovation
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
WSO2CON 2024 - IoT Needs CIAM: The Importance of Centralized IAM in a Growing...
WSO2CON 2024 - IoT Needs CIAM: The Importance of Centralized IAM in a Growing...WSO2CON 2024 - IoT Needs CIAM: The Importance of Centralized IAM in a Growing...
WSO2CON 2024 - IoT Needs CIAM: The Importance of Centralized IAM in a Growing...
 
WSO2CON 2024 - Architecting AI in the Enterprise: APIs and Applications
WSO2CON 2024 - Architecting AI in the Enterprise: APIs and ApplicationsWSO2CON 2024 - Architecting AI in the Enterprise: APIs and Applications
WSO2CON 2024 - Architecting AI in the Enterprise: APIs and Applications
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
WSO2CON 2024 - Software Engineering for Digital Businesses
WSO2CON 2024 - Software Engineering for Digital BusinessesWSO2CON 2024 - Software Engineering for Digital Businesses
WSO2CON 2024 - Software Engineering for Digital Businesses
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
 
WSO2CON 2024 - Designing Event-Driven Enterprises: Stories of Transformation
WSO2CON 2024 - Designing Event-Driven Enterprises: Stories of TransformationWSO2CON 2024 - Designing Event-Driven Enterprises: Stories of Transformation
WSO2CON 2024 - Designing Event-Driven Enterprises: Stories of Transformation
 
WSO2CON 2024 - Not Just Microservices: Rightsize Your Services!
WSO2CON 2024 - Not Just Microservices: Rightsize Your Services!WSO2CON 2024 - Not Just Microservices: Rightsize Your Services!
WSO2CON 2024 - Not Just Microservices: Rightsize Your Services!
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 

Dernier

Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
chiefasafspells
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 

Dernier (20)

Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 

CSV and JSON Transformation in WSO2 Micro Integrator 4.0 - WSO2 APIM Community Call (9/29/2021)

  • 1. WSO2 API Manager Community Call CSV and JSON transformation in MI 4.0.0 September 29th, 2021
  • 2. Hello! Dilan Tharaka Senior Software Engineer dilanth@wso2.com
  • 4. ● Overview ● CSV Connector ● FreeMarker templates in Payload Factory mediator ● Demonstrations What we will be covering today 4
  • 6. Existing Methods to Tansformation 6 ● Data Mapper ● PayloadFactory ● Script Mediator ● XSLT Mediator ● Class Mediator
  • 9. Supporting Transformations in CSV Module 9 ● CSV to CSV transformation ● CSV to JSON transformation ● CSV to XML transformation ● JSON to CSV transformation ● XML to CSV transformation
  • 12. 12 Apache FreeMarker (https://freemarker.apache.org/images/overview.png) ● Free java-based templating engine ● Generated output based of the template and the data model ● Powerful template language: Conditional blocks, iterations, assignments, string and arithmetic operations and formatting, macros and functions
  • 13. Root Variables 13 ● payload ● args ● ctx ● axis2 ● trp
  • 15. JSON to XML 15 { "first_name": "John", "last_name": "Deo", "age": 35, "location": { "state": { " code": "NY", " name": "New York" }, "city": "Manhattan" } } <user> <Name>John Deo</Name> <Age>35</Age> <Address>Manhattan, NY</ Address> </user> <user> <Name>${payload.first_name} ${payload.last_name}</ Name> <Age>${payload.age}</ Age> <Address>${payload.location.city}, ${payload.location.state.code}</ Address> </user> Input Output Template
  • 16. XML to JSON 16 <user> <first_name >John</first_name > <last_name>Deo</last_name> <age>35</age> <location> <state code="NY">New York</ state> <city>Manhattan</ city> </location> </user> { "Name": "John Doe" , "Age": 35, "Address": "Manhattan, NY" } { "Name": "${payload.user.first_name} ${payload.user.last_name}" , "Age": ${payload.user.age} , "Address": "${payload.user.location.city},${payload.user.location.state.@code}" } Input Output Template
  • 17. XML to CSV 17 <people> <person> <id>1</id> <first_name>Veronika</first_name> <last_name>Lacroux</last_name> </person> <person> <id>2</id> <first_name>Trescha</first_name> <last_name>Campaigne</ last_name> </person> </people> ID,First Name, Last Name 1,Veronika,Lacroux 2,Trescha,Campaigne ID,First Name, Last Name <#list payload.people.person as person> ${person.id},${person.first_name},${person.last_name} </#list> Input Output Template
  • 18. Bit more complex transformation 18 { "custID": "cd5322", "custName": "wso2", "tier": "Gold", "items": { "item": [ { "id": "0001", "type": "donut", "name": "Cake", "ppu": 0.55, "batters": { "batter": [ { "id": "1001", "type": "Regular" }, { "id": "1002", "type": "Chocolate" } ] } }, { "id": "0002", "type": "donut", "name": "Raised", "ppu": 0.55, "batters": { "batter": [ { "id": "1001", "type": "Regular" } ] } } ] } } <cd5322 > <cake> <custName tier="Gold"> WSO2</custName > <id>0001</id> <type>donut </type> <ppu>0.55</ppu> <batter > <id>1001</id> <type>Regular </type> </batter > <batter > <id>1002</id> <type>Chocolate </type> </batter > </cake> <cake> <custName tier="Gold"> WSO2</custName > <id>0002</id> <type>donut </type> <ppu>0.55</ppu> <batter > <id>1001</id> <type>Regular </type> </batter > </cake> </cd5322 > Input Output
  • 19. Bit more complex transformation - FreeMarker Template 19 <${payload.custID}> <#list payload.items.item as item> <cake> <custName tier="${payload.tier}">${payload.custName?upper_case}</custName> <id>${item.id}</id> <type>${item.type}</type> <ppu>${item.ppu}</ppu> <#list item.batters.batter as batter> <batter> <id>${batter.id}</id> <type>${batter.type}</type> </batter> </#list> </cake> </#list> </${payload.custID}>
  • 21. ● CSV Module ● Freemarker templates in PayloadFactory mediator ● Apache FreeMarker Useful Links 21