JSON vs GSON vs
JACKSON
- Vinaykumar Hebballi
Topics to cover
 Overview of JSON
 The working of GSON
 The working of JACKSON
 Comparison of JSON,GSON and JACKSON.
 Conclusion
2JSON vs GSON vs JACKSON06/21/16
What is JSON
 JSON is a lightweight data interchange format .
 The most important aspects of JSON are
 Simplicity
 Extensibility
 Interoperability
 Openness and Human readability.
3JSON vs GSON vs JACKSON06/21/16
The working of GSON
 GSON is an Java library to serialize and deserialize Java
objects to (and from) JSON.
 It provides two methods :-
 Gson.toJson to serialize java objects.
 Gson.fromJson to deserialize json objects.
4JSON vs GSON vs JACKSON06/21/16
GSON Example
 Serialization:-
 Gson gson = new Gson();
Car audi = new Car("Audi", "A4", 1.8, false);
Car skoda = new Car(“Skoda", "Octavia", 2.0, true);
Car[] cars = {audi, skoda};
Person johnDoe = new Person("John", "Doe", 245987453, 35,
cars);
System.out.println(gson.toJson(johnDoe));
5JSON vs GSON vs JACKSON06/21/16
GSON Example
 Deserialization:-
 Gson gson = new Gson();
String json = "{"name":"John","surname":"Doe","cars":
[{"manufacturer":"Audi","model":"A4","capacity":1.8,"a
ccident":false},
{"manufacturer":"Škoda","model":"Octavia","capacity":2.
0,"accident":true}], "phone":245987453}";
Person johnDoe = gson.fromJson(json, Person.class);
System.out.println(johnDoe.toString());
6JSON vs GSON vs JACKSON06/21/16
The working of JACKSON
 It is a Java library for processing JSON.
 Jackson aims to be the best possible combination of fast,
correct, lightweight, and friendly for developers.
 Jackson offers three alternative methods:-
 Stream API
 Tree Model
 Data Binding
7JSON vs GSON vs JACKSON06/21/16
JACKSON Example- Data Binding
 Read the Values from JSON file:-
 ObjectMapper mapper = new ObjectMapper();
User user = mapper.readValue(new File("user.json"), User.class);
 Write the values To the JSON file:-
 mapper.writeValue(new File("user-modified.json"), user);
8JSON vs GSON vs JACKSON06/21/16
JACKSON Example- Tree Model
 Tree Model:-
 ObjectMapper mapper = new ObjectMapper();
ArrayNode arrayNode = mapper.createArrayNode();
ObjectNode objectNode = mapper.createObjectNode();
objectNode.put("Firstname", student.getFirstName());
objectNode.put("Lastname",student.getLastName());
objectNode.put("age", student.getAge());
objectNode.put("address", student.getAddress());
objectNode.put("studentId", student.getStudentId());
arrayNode.add(objectNode);
9JSON vs GSON vs JACKSON06/21/16
JACKSON Example- Stream API
 Writing to File:-
JsonFactory f = new JsonFactory();
JsonGenerator g =f.createJsonGenerator(new File("user.json"));
g.writeStartObject();
g.writeStartArray();
g.writeEndArray();
g.writeEndObject();
g.close();
06/21/16 JSON vs GSON vs JACKSON 10
JACKSON Example- Stream API
JsonFactory jfactory = new JsonFactory();
JsonParser jParser = jfactory.createJsonParser(new File("c://temp/user.json"));
while (jParser.nextToken() != JsonToken.END_OBJECT) {
if ("name".equals(fieldname)) {
jParser.nextToken();
System.out.println(jParser.getText()); }
if ("age".equals(fieldname)) {
jParser.nextToken();
System.out.println(jParser.getIntValue()); }
if ("messages".equals(fieldname)) {
jParser.nextToken();
while (jParser.nextToken() != JsonToken.END_ARRAY) {
System.out.println(jParser.getText()); }}
06/21/16 JSON vs GSON vs JACKSON 11
COMPARISON-Big File
12JSON vs GSON vs JACKSON06/21/16
COMPARISON-Small File
13JSON vs GSON vs JACKSON06/21/16
CONCLUSION
 If you are dealing with big JSON files, then Jackson is your
library of interest.
 If you are dealing with with lots of small JSON requests then
GSON is your library of interest.
 If you end up having to often deal with both types of files,
then JSON.simple. Neither Jackson nor GSON perform as
well across multiple files sizes.
14JSON vs GSON vs JACKSON06/21/16
References:
 www.json.org
 http://wiki.fasterxml.com/JacksonHome
 https://google-
gson.googlecode.com/svn/trunk/gson/docs/javadocs/c
om/google/gson/Gson.html
15JSON vs GSON vs JACKSON06/21/16
Thank you

More Related Content

PPTX
Android Workshop PPT
PPTX
Frontend Engineer Hiring Explained at Wix Engineering
PPT
Introduction to Java ME Mobile Development
PPTX
Serialization and performance by Sergey Morenets
PPT
Java JSON Parser Comparison
PPTX
Apache Calcite overview
PDF
Introduction to Apache Calcite
PDF
Streaming SQL with Apache Calcite
Android Workshop PPT
Frontend Engineer Hiring Explained at Wix Engineering
Introduction to Java ME Mobile Development
Serialization and performance by Sergey Morenets
Java JSON Parser Comparison
Apache Calcite overview
Introduction to Apache Calcite
Streaming SQL with Apache Calcite

Similar to Json vs Gson vs Jackson (20)

PDF
Comparing JSON Libraries - July 19 2011
PDF
Json
PDF
Gson tutorial
PPTX
JSON Processing and mule
PDF
Tour de Jackson: Forgotten Features of Jackson JSON processor
PPTX
JSON - (English)
PPTX
Intro to JSON
PPTX
LU 1.3. JSON & XML.pptx about how they work and introduction
PDF
Updates to the java api for json processing for java ee 8
PPTX
JSON-B for CZJUG
PPTX
Introduction to Yasson
PDF
Introduction to JSON
PPTX
What's new in the Java API for JSON Binding
PPTX
All about XML, JSON and related topics..
PPTX
PPTX
Java-JSON-Jackson
PPTX
Json training
PPTX
Json
Comparing JSON Libraries - July 19 2011
Json
Gson tutorial
JSON Processing and mule
Tour de Jackson: Forgotten Features of Jackson JSON processor
JSON - (English)
Intro to JSON
LU 1.3. JSON & XML.pptx about how they work and introduction
Updates to the java api for json processing for java ee 8
JSON-B for CZJUG
Introduction to Yasson
Introduction to JSON
What's new in the Java API for JSON Binding
All about XML, JSON and related topics..
Java-JSON-Jackson
Json training
Json
Ad

Recently uploaded (20)

PDF
CloudStack 4.21: First Look Webinar slides
PDF
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
PPT
Galois Field Theory of Risk: A Perspective, Protocol, and Mathematical Backgr...
PDF
1 - Historical Antecedents, Social Consideration.pdf
PPT
What is a Computer? Input Devices /output devices
PPTX
AI IN MARKETING- PRESENTED BY ANWAR KABIR 1st June 2025.pptx
PPT
Geologic Time for studying geology for geologist
PPTX
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
PPTX
Chapter 5: Probability Theory and Statistics
PDF
Architecture types and enterprise applications.pdf
PDF
“A New Era of 3D Sensing: Transforming Industries and Creating Opportunities,...
PDF
A proposed approach for plagiarism detection in Myanmar Unicode text
PDF
Convolutional neural network based encoder-decoder for efficient real-time ob...
PPTX
GROUP4NURSINGINFORMATICSREPORT-2 PRESENTATION
PPTX
Microsoft Excel 365/2024 Beginner's training
PPTX
Final SEM Unit 1 for mit wpu at pune .pptx
PDF
STKI Israel Market Study 2025 version august
PDF
Getting started with AI Agents and Multi-Agent Systems
PPTX
Custom Battery Pack Design Considerations for Performance and Safety
PPTX
Modernising the Digital Integration Hub
CloudStack 4.21: First Look Webinar slides
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
Galois Field Theory of Risk: A Perspective, Protocol, and Mathematical Backgr...
1 - Historical Antecedents, Social Consideration.pdf
What is a Computer? Input Devices /output devices
AI IN MARKETING- PRESENTED BY ANWAR KABIR 1st June 2025.pptx
Geologic Time for studying geology for geologist
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
Chapter 5: Probability Theory and Statistics
Architecture types and enterprise applications.pdf
“A New Era of 3D Sensing: Transforming Industries and Creating Opportunities,...
A proposed approach for plagiarism detection in Myanmar Unicode text
Convolutional neural network based encoder-decoder for efficient real-time ob...
GROUP4NURSINGINFORMATICSREPORT-2 PRESENTATION
Microsoft Excel 365/2024 Beginner's training
Final SEM Unit 1 for mit wpu at pune .pptx
STKI Israel Market Study 2025 version august
Getting started with AI Agents and Multi-Agent Systems
Custom Battery Pack Design Considerations for Performance and Safety
Modernising the Digital Integration Hub
Ad

Json vs Gson vs Jackson

  • 1. JSON vs GSON vs JACKSON - Vinaykumar Hebballi
  • 2. Topics to cover  Overview of JSON  The working of GSON  The working of JACKSON  Comparison of JSON,GSON and JACKSON.  Conclusion 2JSON vs GSON vs JACKSON06/21/16
  • 3. What is JSON  JSON is a lightweight data interchange format .  The most important aspects of JSON are  Simplicity  Extensibility  Interoperability  Openness and Human readability. 3JSON vs GSON vs JACKSON06/21/16
  • 4. The working of GSON  GSON is an Java library to serialize and deserialize Java objects to (and from) JSON.  It provides two methods :-  Gson.toJson to serialize java objects.  Gson.fromJson to deserialize json objects. 4JSON vs GSON vs JACKSON06/21/16
  • 5. GSON Example  Serialization:-  Gson gson = new Gson(); Car audi = new Car("Audi", "A4", 1.8, false); Car skoda = new Car(“Skoda", "Octavia", 2.0, true); Car[] cars = {audi, skoda}; Person johnDoe = new Person("John", "Doe", 245987453, 35, cars); System.out.println(gson.toJson(johnDoe)); 5JSON vs GSON vs JACKSON06/21/16
  • 6. GSON Example  Deserialization:-  Gson gson = new Gson(); String json = "{"name":"John","surname":"Doe","cars": [{"manufacturer":"Audi","model":"A4","capacity":1.8,"a ccident":false}, {"manufacturer":"Škoda","model":"Octavia","capacity":2. 0,"accident":true}], "phone":245987453}"; Person johnDoe = gson.fromJson(json, Person.class); System.out.println(johnDoe.toString()); 6JSON vs GSON vs JACKSON06/21/16
  • 7. The working of JACKSON  It is a Java library for processing JSON.  Jackson aims to be the best possible combination of fast, correct, lightweight, and friendly for developers.  Jackson offers three alternative methods:-  Stream API  Tree Model  Data Binding 7JSON vs GSON vs JACKSON06/21/16
  • 8. JACKSON Example- Data Binding  Read the Values from JSON file:-  ObjectMapper mapper = new ObjectMapper(); User user = mapper.readValue(new File("user.json"), User.class);  Write the values To the JSON file:-  mapper.writeValue(new File("user-modified.json"), user); 8JSON vs GSON vs JACKSON06/21/16
  • 9. JACKSON Example- Tree Model  Tree Model:-  ObjectMapper mapper = new ObjectMapper(); ArrayNode arrayNode = mapper.createArrayNode(); ObjectNode objectNode = mapper.createObjectNode(); objectNode.put("Firstname", student.getFirstName()); objectNode.put("Lastname",student.getLastName()); objectNode.put("age", student.getAge()); objectNode.put("address", student.getAddress()); objectNode.put("studentId", student.getStudentId()); arrayNode.add(objectNode); 9JSON vs GSON vs JACKSON06/21/16
  • 10. JACKSON Example- Stream API  Writing to File:- JsonFactory f = new JsonFactory(); JsonGenerator g =f.createJsonGenerator(new File("user.json")); g.writeStartObject(); g.writeStartArray(); g.writeEndArray(); g.writeEndObject(); g.close(); 06/21/16 JSON vs GSON vs JACKSON 10
  • 11. JACKSON Example- Stream API JsonFactory jfactory = new JsonFactory(); JsonParser jParser = jfactory.createJsonParser(new File("c://temp/user.json")); while (jParser.nextToken() != JsonToken.END_OBJECT) { if ("name".equals(fieldname)) { jParser.nextToken(); System.out.println(jParser.getText()); } if ("age".equals(fieldname)) { jParser.nextToken(); System.out.println(jParser.getIntValue()); } if ("messages".equals(fieldname)) { jParser.nextToken(); while (jParser.nextToken() != JsonToken.END_ARRAY) { System.out.println(jParser.getText()); }} 06/21/16 JSON vs GSON vs JACKSON 11
  • 12. COMPARISON-Big File 12JSON vs GSON vs JACKSON06/21/16
  • 13. COMPARISON-Small File 13JSON vs GSON vs JACKSON06/21/16
  • 14. CONCLUSION  If you are dealing with big JSON files, then Jackson is your library of interest.  If you are dealing with with lots of small JSON requests then GSON is your library of interest.  If you end up having to often deal with both types of files, then JSON.simple. Neither Jackson nor GSON perform as well across multiple files sizes. 14JSON vs GSON vs JACKSON06/21/16
  • 15. References:  www.json.org  http://wiki.fasterxml.com/JacksonHome  https://google- gson.googlecode.com/svn/trunk/gson/docs/javadocs/c om/google/gson/Gson.html 15JSON vs GSON vs JACKSON06/21/16