文档搜索 > JSR-353 : Java API for Processing JSON

JSR-353 : Java API for Processing JSON

Page 1
<Insert Picture Here>
JSR-353 : Java API for Processing JSON
Jitendra Kotamraju

Page 2
2
The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracles products remains at the sole discretion of Oracle.

Page 3
3
Agenda
?? Overview ?? JAX-RS Usage ?? Standardization

Page 4
4
Overview
?? JSON is a light-weight data exchange format
–? Easy for humans/machines to read and write –? For e.g.:
{"name":"Bob", "age":20, "phone":["276 1234", "123 4567"]}
?? JSON is used by popular web sites in their RESTful web services
–? Facebook, Twitter, Amazon, … –? Twitter Streaming API discontinues XML
JSON

Page 5
5
Overview
JSON usages ?? Policy in Amazon SQS
{ ... "Statement": { "Effect": "Allow", "Principal": { "AWS": "123456789012” }, "Action": "sqs:SendMessage", "Resource": "/987654321098/queue1" } }

Page 6
6
Overview
?? Followers in Twitter API
{ "previous_cursor": 0, "ids": [143206502, 143201767, 777925], "previous_cursor_str": "0", ... }
JSON usages

Page 7
7
JAX-RS
?? JAX-RS applications handle XML using JAXP API XML Usage
@Produces(“application/xml”) public Source getBook(String id) { return new StreamSource(…); }

Page 8
8
JAX-RS
?? JAX-RS applications handle XML using JAXB API XML Usage
@Produces(“application/xml”) public Book getBook(String id) { return new Book(…); }

Page 9
9
JAX-RS
?? JAX-RS content negotiation DataBinding
XML JSON JAX-RS Book
@Produces({“application/xml”, “application/json”}) public Book getBook(String id) { return new Book(); }

Page 10
10
JAX-RS
?? A custom MessageBodyWriter that converts to JSON
–? JSONObject (For e.g. json.org’s API) → JSON –? JAXB → StAX → JSON (For e.g. using jettison) –? POJO/JAXB → JSON (For e.g. using jackson, eclipseLink etc.)
?? No standard API ?? Some solutions have technical limitations ?? Applications/Frameworks need to bundle the libraries JSON Solutions & Limitations

Page 11
11
Standard API
?? Application can use standard types ?? Leaner, portable applications Advantages

Page 12
12
Standard API
?? Parsing/Processing JSON ?? Data binding : JSON text <-> Java Objects ?? Two JSRs: Processing/Parsing (JSON-P), Binding (JSON-B)
–? Similar to JAXP and JAXB –? Close collaboration between the two
Contents

Page 13
13
Java API for Processing JSON (JSON-P)
?? Streaming API to produce/consume JSON
–? Similar to StAX API in XML world
?? Object model API to represent JSON
–? Similar to DOM API in XML world
?? Align with Java EE 7 schedules ?? JSR Supporters
–? fasterxml.com(Jackson), Doug Crockford(json.org)
JSR-353

Page 14
14
JSR-353 : Status
Source: http://blogs.oracle.com/darcy/entry/pictorial_jcp
Here

Page 15
15
JSR-353 Transparency
?? json-processing-spec java.net open source project is used for JSR-353 ?? Mailing lists:
–? users@json-processing-spec.java.net –? jsr353-experts@json-processing-spec.java.net
?? Issue Tracker:
–? http://java.net/jira/browse/JSON_PROCESSING_SPEC
Open Source Project

Page 16
16
Resources
?? http://json-processing-spec.java.net

Page 17
17
Q&A

Page 18
18
Parsing API
JSON Grammar
Source: http://json.org

Page 19
19
Parsing API
JSON Grammar
Source: http://json.org

Page 20
20
JSR-353 API
?? API initial proposal to EG
–? Based visitor pattern (similar to ASM, JSR 269 API, …) –? Works nicely with streaming and tree API –? Providers plug-in their implementations
Processing API

Page 21
21
JSR-353 API
UML class diagram

Page 22
22

设为首页 | 加入收藏 | 昂纲搜索

All Rights Reserved Powered by 文档下载网

Copyright © 2011
文档下载网内容来自网络,如有侵犯请和我们联系。tousu#anggang.com
返回顶部