SlideShare a Scribd company logo
1 of 24
MuleSoft Java-JSON
2
Agenda
• Introduction to JSON
• JSON and Java
• Jackson Annotations
• Introduction to XML
• XML to JSON
• JSON in Mule
• JSON – Java Script Object Notation
• JSON is a data interchange format
• Interactive Web 2.0 applications, no more use
page replacement. Data transfer without
refreshing a page.
• The most important aspects of data transfer are
simplicity, extensibility, interoperability,
openness and human readability
• Key idea in AJAX – Asynchronous Java Script and
XML.
3
Introduction to JSON
• Data is in name/value pairs
• Data is separated by commas
• Curly braces hold objects
• Square brackets hold arrays
4
Syntax of JSON
Simplicity of JSON
• JSON is a subset of Java Script. JSON can be
parsed by a Java Script parser.
• It can represent either complex or simple data
as it has data types
• They are Strings, Number, Boolean, Objects
and Arrays
5
• Array
– ["Sunday", "Monday", "Tuesday", "Wednesday“]
– "employees":[
{"firstName":"John", "lastName":"Doe"},
{"firstName":"Anna", "lastName":"Smith"},
{"firstName":"Peter","lastName":"Jones"}
]
• Object
– { “firstname": “Santhosh ", “lastname": “Gowd”} All data
types are intuitive and similar to other programming
languages
• Also compatible with other languages like C, C++,
C#, ColdFusion, Python and many more.
6
JSON Compatibility
• JSON in AJAX
– Part of HTML Tags
– <html>... <script> var data = JSONdata; </script>...
</html>
• JSON in JavaScript
– XMLHttpRequest
– responseData = eval('(' + responseText + ')');
7
JSON in AJAX
Mapping
8
JSON Java
string java.lang.String
number java.lang.Number
true|false ava.lang.Boolean
null null
array java.util.List
object java.util.Map
Encoding JSON in Java
9
Decoding Java in JSON
10
JSON Schema
• JSON Schema is a specification for JSON based format
for defining the structure of JSON data
• It was written under IETF draft which expired in 2011
– Describes your existing data format.
– Clear, human- and machine-readable documentation.
– Complete structural validation, useful for automated
testing.
– Complete structural validation, validating client-submitted
data.
• Currently the most complete and compliant JSON
Schema validator available is JSV
11
Parsing JSON
• Streaming
• Tree Traversing
• Data Binding
12
JACKSON ANNOTATIONS
13
Jackson Overview
• Jackson is a simple Java-based library to serialize Java
objects to JSON and vice versa
• Features of Jackson
– Easy to use − Jackson API provides a high-level facade to
simplify commonly used use-cases.
– No need to create mapping − Jackson API provides default
mapping for most of the objects to be serialized.
– Performance − Jackson is quite fast, consumes less memory
space, and is suitable for large object graphs or systems.
– Clean JSON − Jackson creates clean and compact JSON results
which are easy to read.
– No Dependency − Jackson library does not require any other
library apart from JDK.
– Open Source − Jackson library is open source and free to use
14
Set up Jackson Environment
• Nothing specific for Jackson
– Install JDK and make sure path and classpath are
set
– Download jackson-all-1.9.0.jar
– Make sure this file is in the classpath in libraries
15
Follow these steps
• Step1 : Create ObjectMapper Object
– ObjectMapper mapper = new ObjectMapper();
• Step 2: Deserialize JSON to Object
– //Object to JSON Conversion Student student =
mapper.readValue(jsonString, Student.class);
• Step 3: Serialize Object to JSON
– jsonString = mapper.writeValueAsString(student);
16
Jackson - Data Binding
• Simple Data Binding
– It converts JSON to and from Java Maps, Lists,
Strings, Numbers, Booleans, and null objects.
• Full Data Binding
– It converts JSON to and from any Java type.
17
Jackson Serialization Annotations
• @JsonAnyGetter
• @JsonGetter
• @JsonPropertyOrder
• @JsonRawValue
• @JsonValue
• @JsonRootName
• @JsonSerialize
18
Jackson Deserialization Annotations
• @JsonCreator
• @JsonProperty
• @JacksonInject
• @JsonAnySetter
• @JsonSetter
• @JsonDeserialize
19
Jackson Property Inclusion
Annotations
• @JsonIgnoreProperties
• @JsonIgnore
• @JsonIgnoreType
• @JsonInclude
• @JsonAutoDetect
20
Jackson Polymorphic Type
Handling Annotations
• @JsonTypeInfo is used to indicate details of
what type information is included in
serialization
• @JsonSubTypes is used to indicate sub-types
of annotated type
• @JsonTypeName is used to define logical type
name to use for annotated class
21
Jackson General Annotations
• @JsonProperty
• @JsonFormat
• @JsonUnwrapped
• @JsonView
• @JsonManagedReference
• @JsonBackReference
• @JsonIdentityInfo
• @JsonFilter
22
JSON in Mule
• JSON Converters
• Configuring the components
• Mix ins
• Inbuilt Jackson API in Mule.
12/16/2015 23
References
• www.json.org
• http://www.w3schools.com/json/json_intro.asp
• http://www.tutorialspoint.com/json/index.htm
• http://www.tutorialspoint.com/jackson/jackson_quic
k_guide.htm
• http://www.baeldung.com/jackson-annotations
24

More Related Content

What's hot

Ecto Introduction by Patrick Vanstee
Ecto Introduction by Patrick VansteeEcto Introduction by Patrick Vanstee
Ecto Introduction by Patrick Vansteejasnow
 
Tour de Jackson: Forgotten Features of Jackson JSON processor
Tour de Jackson: Forgotten Features of Jackson JSON processorTour de Jackson: Forgotten Features of Jackson JSON processor
Tour de Jackson: Forgotten Features of Jackson JSON processorTatu Saloranta
 
Android Level 2
Android Level 2Android Level 2
Android Level 2DevMix
 
iOS: Web Services and XML parsing
iOS: Web Services and XML parsingiOS: Web Services and XML parsing
iOS: Web Services and XML parsingJussi Pohjolainen
 
Fun with Functional Programming in Clojure
Fun with Functional Programming in ClojureFun with Functional Programming in Clojure
Fun with Functional Programming in ClojureCodemotion
 
Mongo DB: Fundamentals & Basics/ An Overview of MongoDB/ Mongo DB tutorials
Mongo DB: Fundamentals & Basics/ An Overview of MongoDB/ Mongo DB tutorialsMongo DB: Fundamentals & Basics/ An Overview of MongoDB/ Mongo DB tutorials
Mongo DB: Fundamentals & Basics/ An Overview of MongoDB/ Mongo DB tutorialsSpringPeople
 
04 data accesstechnologies
04 data accesstechnologies04 data accesstechnologies
04 data accesstechnologiesBat Programmer
 
MongoDB basics & Introduction
MongoDB basics & IntroductionMongoDB basics & Introduction
MongoDB basics & IntroductionJerwin Roy
 
NoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love StoryNoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love StoryAlexandre Morgaut
 
MongoDB for Beginners
MongoDB for BeginnersMongoDB for Beginners
MongoDB for BeginnersEnoch Joshua
 
Mule soft mel_day1
Mule soft mel_day1Mule soft mel_day1
Mule soft mel_day1abhipokharna
 
Database Programming
Database ProgrammingDatabase Programming
Database ProgrammingHenry Osborne
 

What's hot (20)

Ruby de Rails
Ruby de RailsRuby de Rails
Ruby de Rails
 
Ecto Introduction by Patrick Vanstee
Ecto Introduction by Patrick VansteeEcto Introduction by Patrick Vanstee
Ecto Introduction by Patrick Vanstee
 
Tour de Jackson: Forgotten Features of Jackson JSON processor
Tour de Jackson: Forgotten Features of Jackson JSON processorTour de Jackson: Forgotten Features of Jackson JSON processor
Tour de Jackson: Forgotten Features of Jackson JSON processor
 
Android Level 2
Android Level 2Android Level 2
Android Level 2
 
Node js crash course session 6
Node js crash course   session 6Node js crash course   session 6
Node js crash course session 6
 
iOS: Web Services and XML parsing
iOS: Web Services and XML parsingiOS: Web Services and XML parsing
iOS: Web Services and XML parsing
 
Fun with Functional Programming in Clojure
Fun with Functional Programming in ClojureFun with Functional Programming in Clojure
Fun with Functional Programming in Clojure
 
Ajax
AjaxAjax
Ajax
 
Linq
LinqLinq
Linq
 
Ajax
AjaxAjax
Ajax
 
Mongo DB: Fundamentals & Basics/ An Overview of MongoDB/ Mongo DB tutorials
Mongo DB: Fundamentals & Basics/ An Overview of MongoDB/ Mongo DB tutorialsMongo DB: Fundamentals & Basics/ An Overview of MongoDB/ Mongo DB tutorials
Mongo DB: Fundamentals & Basics/ An Overview of MongoDB/ Mongo DB tutorials
 
Json parser
Json parserJson parser
Json parser
 
04 data accesstechnologies
04 data accesstechnologies04 data accesstechnologies
04 data accesstechnologies
 
java script json
java script jsonjava script json
java script json
 
MongoDB basics & Introduction
MongoDB basics & IntroductionMongoDB basics & Introduction
MongoDB basics & Introduction
 
NoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love StoryNoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love Story
 
MongoDB for Beginners
MongoDB for BeginnersMongoDB for Beginners
MongoDB for Beginners
 
Mule soft mel_day1
Mule soft mel_day1Mule soft mel_day1
Mule soft mel_day1
 
Database Programming
Database ProgrammingDatabase Programming
Database Programming
 
Meteor Modelling
Meteor ModellingMeteor Modelling
Meteor Modelling
 

Similar to JSON Processing and mule

Easy JSON Data Manipulation in Spark
Easy JSON Data Manipulation in SparkEasy JSON Data Manipulation in Spark
Easy JSON Data Manipulation in SparkYin Huai
 
Json in Postgres - the Roadmap
 Json in Postgres - the Roadmap Json in Postgres - the Roadmap
Json in Postgres - the RoadmapEDB
 
module 2.pptx for full stack mobile development application on backend applic...
module 2.pptx for full stack mobile development application on backend applic...module 2.pptx for full stack mobile development application on backend applic...
module 2.pptx for full stack mobile development application on backend applic...HemaSenthil5
 
Json - ideal for data interchange
Json - ideal for data interchangeJson - ideal for data interchange
Json - ideal for data interchangeChristoph Santschi
 
JSON - (English)
JSON - (English)JSON - (English)
JSON - (English)Senior Dev
 
BITM3730Week8.pptx
BITM3730Week8.pptxBITM3730Week8.pptx
BITM3730Week8.pptxMattMarino13
 
Iasi code camp 12 october 2013 jax-rs-jee-ecosystem - catalin mihalache
Iasi code camp 12 october 2013   jax-rs-jee-ecosystem - catalin mihalacheIasi code camp 12 october 2013   jax-rs-jee-ecosystem - catalin mihalache
Iasi code camp 12 october 2013 jax-rs-jee-ecosystem - catalin mihalacheCodecamp Romania
 
Web technologies-course 10.pptx
Web technologies-course 10.pptxWeb technologies-course 10.pptx
Web technologies-course 10.pptxStefan Oprea
 
Demystifying JSON in SQL Server
Demystifying JSON in SQL ServerDemystifying JSON in SQL Server
Demystifying JSON in SQL Serverkristinferrier
 
Json – java script object notation
Json – java script object notationJson – java script object notation
Json – java script object notationPankaj Srivastava
 
Java JSON Parser Comparison
Java JSON Parser ComparisonJava JSON Parser Comparison
Java JSON Parser ComparisonAllan Huang
 

Similar to JSON Processing and mule (20)

Java-JSON-Jackson
Java-JSON-JacksonJava-JSON-Jackson
Java-JSON-Jackson
 
Json
JsonJson
Json
 
JSON
JSONJSON
JSON
 
Unit-2.pptx
Unit-2.pptxUnit-2.pptx
Unit-2.pptx
 
Easy JSON Data Manipulation in Spark
Easy JSON Data Manipulation in SparkEasy JSON Data Manipulation in Spark
Easy JSON Data Manipulation in Spark
 
Json in Postgres - the Roadmap
 Json in Postgres - the Roadmap Json in Postgres - the Roadmap
Json in Postgres - the Roadmap
 
module 2.pptx for full stack mobile development application on backend applic...
module 2.pptx for full stack mobile development application on backend applic...module 2.pptx for full stack mobile development application on backend applic...
module 2.pptx for full stack mobile development application on backend applic...
 
Json - ideal for data interchange
Json - ideal for data interchangeJson - ideal for data interchange
Json - ideal for data interchange
 
JSON - (English)
JSON - (English)JSON - (English)
JSON - (English)
 
Introduction to Yasson
Introduction to YassonIntroduction to Yasson
Introduction to Yasson
 
JSON Injection
JSON InjectionJSON Injection
JSON Injection
 
BITM3730Week8.pptx
BITM3730Week8.pptxBITM3730Week8.pptx
BITM3730Week8.pptx
 
Iasi code camp 12 october 2013 jax-rs-jee-ecosystem - catalin mihalache
Iasi code camp 12 october 2013   jax-rs-jee-ecosystem - catalin mihalacheIasi code camp 12 october 2013   jax-rs-jee-ecosystem - catalin mihalache
Iasi code camp 12 october 2013 jax-rs-jee-ecosystem - catalin mihalache
 
Web technologies-course 10.pptx
Web technologies-course 10.pptxWeb technologies-course 10.pptx
Web technologies-course 10.pptx
 
Json processing
Json processingJson processing
Json processing
 
Demystifying JSON in SQL Server
Demystifying JSON in SQL ServerDemystifying JSON in SQL Server
Demystifying JSON in SQL Server
 
Json tutorial, a beguiner guide
Json tutorial, a beguiner guideJson tutorial, a beguiner guide
Json tutorial, a beguiner guide
 
Introduction to JSON
Introduction to JSONIntroduction to JSON
Introduction to JSON
 
Json – java script object notation
Json – java script object notationJson – java script object notation
Json – java script object notation
 
Java JSON Parser Comparison
Java JSON Parser ComparisonJava JSON Parser Comparison
Java JSON Parser Comparison
 

Recently uploaded

My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
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
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 

Recently uploaded (20)

My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
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
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 

JSON Processing and mule

  • 2. 2 Agenda • Introduction to JSON • JSON and Java • Jackson Annotations • Introduction to XML • XML to JSON • JSON in Mule
  • 3. • JSON – Java Script Object Notation • JSON is a data interchange format • Interactive Web 2.0 applications, no more use page replacement. Data transfer without refreshing a page. • The most important aspects of data transfer are simplicity, extensibility, interoperability, openness and human readability • Key idea in AJAX – Asynchronous Java Script and XML. 3 Introduction to JSON
  • 4. • Data is in name/value pairs • Data is separated by commas • Curly braces hold objects • Square brackets hold arrays 4 Syntax of JSON
  • 5. Simplicity of JSON • JSON is a subset of Java Script. JSON can be parsed by a Java Script parser. • It can represent either complex or simple data as it has data types • They are Strings, Number, Boolean, Objects and Arrays 5
  • 6. • Array – ["Sunday", "Monday", "Tuesday", "Wednesday“] – "employees":[ {"firstName":"John", "lastName":"Doe"}, {"firstName":"Anna", "lastName":"Smith"}, {"firstName":"Peter","lastName":"Jones"} ] • Object – { “firstname": “Santhosh ", “lastname": “Gowd”} All data types are intuitive and similar to other programming languages • Also compatible with other languages like C, C++, C#, ColdFusion, Python and many more. 6 JSON Compatibility
  • 7. • JSON in AJAX – Part of HTML Tags – <html>... <script> var data = JSONdata; </script>... </html> • JSON in JavaScript – XMLHttpRequest – responseData = eval('(' + responseText + ')'); 7 JSON in AJAX
  • 8. Mapping 8 JSON Java string java.lang.String number java.lang.Number true|false ava.lang.Boolean null null array java.util.List object java.util.Map
  • 10. Decoding Java in JSON 10
  • 11. JSON Schema • JSON Schema is a specification for JSON based format for defining the structure of JSON data • It was written under IETF draft which expired in 2011 – Describes your existing data format. – Clear, human- and machine-readable documentation. – Complete structural validation, useful for automated testing. – Complete structural validation, validating client-submitted data. • Currently the most complete and compliant JSON Schema validator available is JSV 11
  • 12. Parsing JSON • Streaming • Tree Traversing • Data Binding 12
  • 14. Jackson Overview • Jackson is a simple Java-based library to serialize Java objects to JSON and vice versa • Features of Jackson – Easy to use − Jackson API provides a high-level facade to simplify commonly used use-cases. – No need to create mapping − Jackson API provides default mapping for most of the objects to be serialized. – Performance − Jackson is quite fast, consumes less memory space, and is suitable for large object graphs or systems. – Clean JSON − Jackson creates clean and compact JSON results which are easy to read. – No Dependency − Jackson library does not require any other library apart from JDK. – Open Source − Jackson library is open source and free to use 14
  • 15. Set up Jackson Environment • Nothing specific for Jackson – Install JDK and make sure path and classpath are set – Download jackson-all-1.9.0.jar – Make sure this file is in the classpath in libraries 15
  • 16. Follow these steps • Step1 : Create ObjectMapper Object – ObjectMapper mapper = new ObjectMapper(); • Step 2: Deserialize JSON to Object – //Object to JSON Conversion Student student = mapper.readValue(jsonString, Student.class); • Step 3: Serialize Object to JSON – jsonString = mapper.writeValueAsString(student); 16
  • 17. Jackson - Data Binding • Simple Data Binding – It converts JSON to and from Java Maps, Lists, Strings, Numbers, Booleans, and null objects. • Full Data Binding – It converts JSON to and from any Java type. 17
  • 18. Jackson Serialization Annotations • @JsonAnyGetter • @JsonGetter • @JsonPropertyOrder • @JsonRawValue • @JsonValue • @JsonRootName • @JsonSerialize 18
  • 19. Jackson Deserialization Annotations • @JsonCreator • @JsonProperty • @JacksonInject • @JsonAnySetter • @JsonSetter • @JsonDeserialize 19
  • 20. Jackson Property Inclusion Annotations • @JsonIgnoreProperties • @JsonIgnore • @JsonIgnoreType • @JsonInclude • @JsonAutoDetect 20
  • 21. Jackson Polymorphic Type Handling Annotations • @JsonTypeInfo is used to indicate details of what type information is included in serialization • @JsonSubTypes is used to indicate sub-types of annotated type • @JsonTypeName is used to define logical type name to use for annotated class 21
  • 22. Jackson General Annotations • @JsonProperty • @JsonFormat • @JsonUnwrapped • @JsonView • @JsonManagedReference • @JsonBackReference • @JsonIdentityInfo • @JsonFilter 22
  • 23. JSON in Mule • JSON Converters • Configuring the components • Mix ins • Inbuilt Jackson API in Mule. 12/16/2015 23
  • 24. References • www.json.org • http://www.w3schools.com/json/json_intro.asp • http://www.tutorialspoint.com/json/index.htm • http://www.tutorialspoint.com/jackson/jackson_quic k_guide.htm • http://www.baeldung.com/jackson-annotations 24