Java JSON Parser Comparison

24
Java JSON Parser Comparison Allan Huang @ Delta DRC

description

 

Transcript of Java JSON Parser Comparison

Page 1: Java JSON Parser Comparison

Java JSON Parser Comparison

Allan Huang @ Delta DRC

Page 2: Java JSON Parser Comparison

Agenda

JSON Java API for RESTful Web Services Java API for JSON Processing Java EE Compatible Implementations

JSON Parser Evaluation Criterion Parser Candidates Evaluation Matrix

Page 3: Java JSON Parser Comparison

JSON

Page 4: Java JSON Parser Comparison

JSON

JavaScript Object Notation A lightweight, text-based, language-independent

data exchange format. Built on two structures…

A collection of name/value pairs, realized as Object: { } or Hash Table.

An ordered list of values, realized as an Array: [ ]. Used in AJAX applications, configurations,

NoSQL databases, and RESTful web services

Page 5: Java JSON Parser Comparison

Java API for RESTful Web Services

Defined as JSR 339 in Java EE 7 JAX-RS 2.0 specification Use HTTP methods to interact with the resource

GET to retrieve a resource POST to create a resource PUT to update a resource DELETE to remove a resource

Communication between the client and the endpoint is Stateless.

Page 6: Java JSON Parser Comparison

Java API for JSON Processing

Defined as JSR 353 in Java EE 7 Streaming API

JSON Pull Parser Similar to StAX API for XML Uses an event-based parser that reads JSON data one

element at a time. Object Model API

JSON Push Parser Similar to DOM API for XML Creates a object tree that represents the JSON data in

memory.

Page 7: Java JSON Parser Comparison

Streaming API

Generates JSON output to a given stream by making a function call with one element at a time.

Provides forward, read-only access to the JSON data.

Page 8: Java JSON Parser Comparison

Streaming API Example

Json Parser Json Generator

Page 9: Java JSON Parser Comparison

Object Model API

Generates JSON output by navigating the entire tree at once.

It’s slower than streaming model and requires more memory.

Page 10: Java JSON Parser Comparison

Object Model API Example

Json Reader Json Writer

Page 11: Java JSON Parser Comparison

Model API Comparison

If you want to… read a large amount

of JSON. write JSON to a

char/byte stream. random access

JSON in memory. reuse JSON without

need to reparse.

Page 12: Java JSON Parser Comparison

Java EE 7 Compatible Implementations

Full Platform distribution Web Profile distribution

Page 13: Java JSON Parser Comparison

Java EE 6 Compatible Implementations (1)

Full Platform distribution

Page 14: Java JSON Parser Comparison

Java EE 6 Compatible Implementations (2)

Web Profile distributions

Page 15: Java JSON Parser Comparison

Java EE FAQ

Web Profile vs. Full Platform Java EE introduced the lightweight Web Profile

optimized for web applications. e.g. GlassFish Server Open Source Edition 3.1.x TomEE

An all-Apache Java EE Web Profile certified stack where Apache Tomcat is top dog.

Current version 1.7 supports Java EE 6 Next version 2.x support Java EE 7

Wildfly – formerly known as JBoss AS

Page 16: Java JSON Parser Comparison

JSON Parser

Page 17: Java JSON Parser Comparison

Evaluation Criterion (1)

Community Activity Repository, Organization, Downloads (>10000),

Project References Performance Ranking Revision

Previous Release Date, Last Release Date, Last Revision Number, Revision Frequency, Total Open Issues

Page 18: Java JSON Parser Comparison

Evaluation Criterion (2)

API Richness Object Model API, Streaming API support, Java

Annotation, Serialization / De-serialization, Documentation & Example

Dependency 3rd-party Libraries Minimum JDK Version

License MIT, BSD, Apache 2.0 ...

Page 19: Java JSON Parser Comparison

License

Page 21: Java JSON Parser Comparison

Parser Matrix  Java JSON Parser

Criteria javax json Jackson Google GSON json.org json-lib json-simple json-smart flexjson fastjson

Community Activity

Repository Oracle Java Net GitHub Google Code GitHub Sourceforge Google Code Google Code Sourceforge GitHub

Organization Oracle N/A Google JSON org N/A N/A N/A N/A Alibaba

Downloads Unknown Unknown 521,946 Unknown 316,668 228,839 12,213 48,276 8,412

Project References 40 215 forks 8 1268 forks 12 33 7 Unknown 586 forks

PerformanceRanking

Top 7 Open-Source (Small)

N/A 3 1 N/A 4 N/A N/A 2 N/A

Top 7 Open-Source (Large)

N/A 1 3 N/A 2 N/A N/A 4 N/A

JSON serialization benchmarks

N/A 1 2 N/A N/A N/A N/A N/A N/A

Revisiting a (JSON) Benchmark

N/A 1 2 N/A N/A N/A N/A N/A N/A

jvm-serializers N/A 1 3 6 8 5 4 7 2

json-parsers-benchmark

(Boon)N/A 1 2 N/A N/A N/A 3 N/A N/A

Json BecnhMark(json-smart)

N/A 3 N/A 5 6 4 1 N/A 2

Revision

Previous Release Date

Unknown 2014/8/15 2013/5/13 Unknown 2009/7/11 2009/2/15 2013/8/13 2013/5/19 2014/5/20

Last Release Date 2013/11/18 2014/10/4 2014/8/11 2014/5/22 2010/12/14 2012/2/18 2013/8/15 2013/7/31 2014/10/11

Last Revision Number

1.0.4 2.4.3 2.3 N/A 2.4 1.1.1 2.0-RC3 3.2 1.1.42

Revision Frequency Sometimes Always Sometimes Often No Longer No Longer Rarely Rarely Often

Total Open Issues 6 bugs7 issues

2 pull reqeusts84 defects

32 enhancements 3 pull requests 35 bugs

10 defects16 enhancements

5 defects2 enhancements

8 bugs 10 issues

API Richness

Object Model API Support

Yes Yes Yes Yes Yes Yes Yes Yes Yes

Streaming API Support

Yes Yes Yes No No Yes Yes No Yes

Java Annotation Yes Yes Yes No No No No Yes Yes

Serialization & De-serialization

Yes Yes Yes YesYes, but hard to

use No

Yes, but hard to use

Yes Yes

Documentation & Example

Rich Rich Rich Poor Enough Enough Poor Poor Enough

Dependency3rd-party Libraries 0 0 0 0 Apache commons 0 0 0 0

Minimum JDK Version

1.7 1.6 1.6 1.8 1.5 1.2 1.5 1.6 1.5

License LicenseCDDL 1.1

GPL 2.0Apache 2.0

LGPL 2.1Apache 2.0 Apache 2.0 Apache 2.0 Apache 2.0 Apache 2.0 Apache 2.0 Apache 2.0

Page 22: Java JSON Parser Comparison

Conclusion

“Top 7 Open-Source JSON-Binding Providers Available Today” said… Google GSON

Process small size data Jackson

Process large size data

Upgrade Java EE 7 application server? Use Open-Source solution? Which parser is best for RAM / IoT?

Page 23: Java JSON Parser Comparison

Reference Java API for JSON Processing: An Introduction to JSON Creating JSON Data Using The Java JSON API (JSR 353) Java JSON Processing API Example Tutorial Top 7 Open-Source JSON-Binding Providers Available Today Java EE 7/6 Compatibility Java EE FAQ GlassFish Server Open Source Edition 3.1.x Apache TomEE Support JSON JSR 353 - Java API for JSON Processing (JSON-P) 軟體的授權觀念與自由軟體授權條款介紹

Page 24: Java JSON Parser Comparison

Q&A