SlideShare a Scribd company logo
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
JSON Support in Java EE 8
JSON-P, JSON-B, Yasson
Dmitry Kornilov
JSONB/P Specifications Lead
@m0mus
28 Aug 2017
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Safe Harbor Statement
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 Oracle’s products remains at the sole discretion of Oracle.
2
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 3
Dmitry Kornilov
• Senior Manager @ Oracle
• JSON-B (JSR-367) spec lead
• JSON-P (JSR-374) spec lead
• Outstanding Spec Lead 2016
• EclipseLink project committer
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Program Agenda
Introduction
JSON Processing
JSON Binding / Yasson
Q & A
1
2
3
5
4
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Introduction
5
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 6
What is JSON???
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
This is Jason
7
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
This is also Jason
8
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
This is JSON-B
9
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
What is JSON?
• JavaScript Object Notation
• Subset of JavaScript
• Lightweight data-interchange format
• Object, Array, Value
10
{
"name": "Jason Bourne",
"age": 35,
"phoneNumbers": [
{
"type": "home",
"number": "123-456-789"
}
]
}
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
JSON Support in Java EE 8
• JSON Processing API
– Standard API to parse, generate, transform, query JSON
– Object Model and Streaming API
• similar to DOM and StAX
• JSON Binding API
– Binding JSON documents to Java objects
• similar to JAXB
11
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
JSON Processing
12
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
JSON-P Links
• JSON-P Public Web Site
– https://javaee.github.io/jsonp/
• GitHub
– https://github.com/javaee/jsonp
• JCP
– https://jcp.org/en/jsr/detail?id=374
• Discussion Groups
– https://javaee.groups.io/g/jsonp-spec
13
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Maven Dependencies
14
<!-- JSON-P API & RI -->
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId>
<version>1.1</version>
</dependency>
<!-- JSON-P API -->
<dependency>
<groupId>javax.json</groupId>
<artifactId>javax.json-api</artifactId>
<version>1.1</version>
</dependency>
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
JSON-P
• Streaming API
– JsonParser
– JsonGenerator
• Object model API
– JsonReader
– JsonWriter
– JsonPointer
– JsonPatch
– JsonMergePatch
15
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
JsonParser
• JsonParser
– Parses JSON in a streaming way from input sources
– Similar to StAX’s XMLStreamReader, a pull parser
• Created using:
• Json.createParser(…), Json.createParserFactory().createParser(…)
• Optionally, configured with features
• Parser state events:
– START_ARRAY, START_OBJECT, KEY_NAME, VALUE_STRING, VALUE_NUMBER,
VALUE_TRUE, VALUE_FALSE, VALUE_NULL, END_OBJECT, END_ARRAY
16
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 17
JsonParser
{
"name":
"Jason Bourne",
"age":
35,
"phoneNumbers":
[
{
"type": "home",
"number": "123-456-789"
}
]
}
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 18
JsonParser
START_OBJECT{
"name":
"Jason Bourne",
"age":
35,
"phoneNumbers":
[
{
"type": "home",
"number": "123-456-789"
}
]
}
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 19
JsonParser
START_OBJECT
KEY_NAME
{
"name":
"Jason Bourne",
"age":
35,
"phoneNumbers":
[
{
"type": "home",
"number": "123-456-789"
}
]
}
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 20
JsonParser
START_OBJECT
KEY_NAME
VALUE_STRING
{
"name":
"Jason Bourne",
"age":
35,
"phoneNumbers":
[
{
"type": "home",
"number": "123-456-789"
}
]
}
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 21
JsonParser
START_OBJECT
KEY_NAME
VALUE_STRING
KEY_NAME
{
"name":
"Jason Bourne",
"age":
35,
"phoneNumbers":
[
{
"type": "home",
"number": "123-456-789"
}
]
}
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 22
JsonParser
START_OBJECT
KEY_NAME
VALUE_STRING
KEY_NAME
VALUE_NUMBER
{
"name":
"Jason Bourne",
"age":
35,
"phoneNumbers":
[
{
"type": "home",
"number": "123-456-789"
}
]
}
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 23
JsonParser
START_OBJECT
KEY_NAME
VALUE_STRING
KEY_NAME
VALUE_NUMBER
KEY_NAME
{
"name":
"Jason Bourne",
"age":
35,
"phoneNumbers":
[
{
"type": "home",
"number": "123-456-789"
}
]
}
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 24
JsonParser
START_OBJECT
KEY_NAME
VALUE_STRING
KEY_NAME
VALUE_NUMBER
KEY_NAME
START_ARRAY
{
"name":
"Jason Bourne",
"age":
35,
"phoneNumbers":
[
{
"type": "home",
"number": "123-456-789"
}
]
}
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 25
JsonParser
START_OBJECT
KEY_NAME
VALUE_STRING
KEY_NAME
VALUE_NUMBER
KEY_NAME
START_ARRAY
START_OBJECT
{
"name":
"Jason Bourne",
"age":
35,
"phoneNumbers":
[
{
"type": "home",
"number": "123-456-789"
}
]
}
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 26
JsonParser
START_OBJECT
KEY_NAME
VALUE_STRING
KEY_NAME
VALUE_NUMBER
KEY_NAME
START_ARRAY
START_OBJECT
KEY_NAME, VALUE_STRING
{
"name":
"Jason Bourne",
"age":
35,
"phoneNumbers":
[
{
"type": "home",
"number": "123-456-789"
}
]
}
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 27
JsonParser
START_OBJECT
KEY_NAME
VALUE_STRING
KEY_NAME
VALUE_NUMBER
KEY_NAME
START_ARRAY
START_OBJECT
KEY_NAME, VALUE_STRING
KEY_NAME, VALUE_STRING
{
"name":
"Jason Bourne",
"age":
35,
"phoneNumbers":
[
{
"type": "home",
"number": "123-456-789"
}
]
}
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 28
JsonParser
START_OBJECT
KEY_NAME
VALUE_STRING
KEY_NAME
VALUE_NUMBER
KEY_NAME
START_ARRAY
START_OBJECT
KEY_NAME, VALUE_STRING
KEY_NAME, VALUE_STRING
END_OBJECT
{
"name":
"Jason Bourne",
"age":
35,
"phoneNumbers":
[
{
"type": "home",
"number": "123-456-789"
}
]
}
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 29
JsonParser
START_OBJECT
KEY_NAME
VALUE_STRING
KEY_NAME
VALUE_NUMBER
KEY_NAME
START_ARRAY
START_OBJECT
KEY_NAME, VALUE_STRING
KEY_NAME, VALUE_STRING
END_OBJECT
END_ARRAY
{
"name":
"Jason Bourne",
"age":
35,
"phoneNumbers":
[
{
"type": "home",
"number": "123-456-789"
}
]
}
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 30
JsonParser
START_OBJECT
KEY_NAME
VALUE_STRING
KEY_NAME
VALUE_NUMBER
KEY_NAME
START_ARRAY
START_OBJECT
KEY_NAME, VALUE_STRING
KEY_NAME, VALUE_STRING
END_OBJECT
END_ARRAY
END_OBJECT
{
"name":
"Jason Bourne",
"age":
35,
"phoneNumbers":
[
{
"type": "home",
"number": "123-456-789"
}
]
}
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 31
JsonParser
{
"name":
"Jason Bourne",
"age":
35,
"phoneNumbers":
[
{
"type": "home",
"number": "123-456-789"
}
]
}
JsonParser parser = Json.createParser(...);
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 32
JsonParser
{
"name":
"Jason Bourne",
"age":
35,
"phoneNumbers":
[
{
"type": "home",
"number": "123-456-789"
}
]
}
JsonParser parser = Json.createParser(...);
Event e = parser.next(); // START_OBJECT
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 33
JsonParser
{
"name":
"Jason Bourne",
"age":
35,
"phoneNumbers":
[
{
"type": "home",
"number": "123-456-789"
}
]
}
JsonParser parser = Json.createParser(...);
Event e = parser.next(); // START_OBJECT
parser.next(); // KEY_NAME
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 34
JsonParser
{
"name":
"Jason Bourne",
"age":
35,
"phoneNumbers":
[
{
"type": "home",
"number": "123-456-789"
}
]
}
JsonParser parser = Json.createParser(...);
Event e = parser.next(); // START_OBJECT
parser.next(); // KEY_NAME
parser.getString(); // name
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 35
JsonParser
{
"name":
"Jason Bourne",
"age":
35,
"phoneNumbers":
[
{
"type": "home",
"number": "123-456-789"
}
]
}
JsonParser parser = Json.createParser(...);
Event e = parser.next(); // START_OBJECT
parser.next(); // KEY_NAME
parser.getString(); // name
parser.next(); // VALUE_STRING
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 36
JsonParser
{
"name":
"Jason Bourne",
"age":
35,
"phoneNumbers":
[
{
"type": "home",
"number": "123-456-789"
}
]
}
JsonParser parser = Json.createParser(...);
Event e = parser.next(); // START_OBJECT
parser.next(); // KEY_NAME
parser.getString(); // name
parser.next(); // VALUE_STRING
parser.getString(); // Jason Bourne
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 37
JsonParser
{
"name":
"Jason Bourne",
"age":
35,
"phoneNumbers":
[
{
"type": "home",
"number": "123-456-789"
}
]
}
JsonParser parser = Json.createParser(...);
Event e = parser.next(); // START_OBJECT
parser.next(); // KEY_NAME
parser.getString(); // name
parser.next(); // VALUE_STRING
parser.getString(); // Jason Bourne
parser.next(); // KEY_NAME
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 38
JsonParser
{
"name":
"Jason Bourne",
"age":
35,
"phoneNumbers":
[
{
"type": "home",
"number": "123-456-789"
}
]
}
JsonParser parser = Json.createParser(...);
Event e = parser.next(); // START_OBJECT
parser.next(); // KEY_NAME
parser.getString(); // name
parser.next(); // VALUE_STRING
parser.getString(); // Jason Bourne
parser.next(); // KEY_NAME
parser.getString(); // age
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 39
JsonParser
{
"name":
"Jason Bourne",
"age":
35,
"phoneNumbers":
[
{
"type": "home",
"number": "123-456-789"
}
]
}
JsonParser parser = Json.createParser(...);
Event e = parser.next(); // START_OBJECT
parser.next(); // KEY_NAME
parser.getString(); // name
parser.next(); // VALUE_STRING
parser.getString(); // Jason Bourne
parser.next(); // KEY_NAME
parser.getString(); // age
parser.next(); // VALUE_NUMBER
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 40
JsonParser
{
"name":
"Jason Bourne",
"age":
35,
"phoneNumbers":
[
{
"type": "home",
"number": "123-456-789"
}
]
}
JsonParser parser = Json.createParser(...);
Event e = parser.next(); // START_OBJECT
parser.next(); // KEY_NAME
parser.getString(); // name
parser.next(); // VALUE_STRING
parser.getString(); // Jason Bourne
parser.next(); // KEY_NAME
parser.getString(); // age
parser.next(); // VALUE_NUMBER
parser.getInt(); // 35
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
JsonGenerator
• Generates JSON in a streaming way to output sources
– Similar to StAX’s XMLStreamWriter
• Created using:
– Json.createGenerator(…)
– Json.createGeneratorFactory().createGenerator(…)
• Optionally, configured with features
– e.g. pretty printing
• Allows method chaining
41
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 42
JsonGenerator
JsonGenerator ge=Json.createGenerator(…);
ge.writeStartArray()
.writeStartObject()
.write("type", "home”)
.write("number", "123-456-789")
.writeEnd()
.writeStartObject()
.write("type", "fax”)
.write("number", "123-456-790")
.writeEnd()
.writeEnd()
.close();
[
{
"type": "home”,
"number": "123-456-789"
},
{
"type": "fax”,
"number": "123-456-790"
}
]
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Object Model API
• Builder to build JsonObject and JsonArray from scratch
• Allows method chaining
• Type-safe (cannot mix array and object building methods)
• Can also use existing JsonObject and JsonArray in a builder
43
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 44
Object Model API
JsonArray value = Json.createArrayBuilder()
.add(Json.createObjectBuilder()
.add("type", "home")
.add("number", "123-456-789")
.build();
)
.add(Json.createObjectBuilder()
.add("type", "fax")
.add("number", "123-456-790")
.build()
)
.build();
[
{
"type": "home”,
"number": "123-456-789"
},
{
"type": "fax”,
"number": "123-456-790"
}
]
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
JSON-P 1.1
• Update JSON-P spec to stay current with emerging standards (RFC 7159)
• Support for IETF standards on
– JSON Pointer (RFC 6901)
– JSON Patch (RFC 6902)
– JSON Merge Patch (RFC 7396)
• Add editing/transformation operations to JSON objects and arrays
• Support for a streaming API, together with Collectors
• Support for processing big JSON, e.g. add filters to JSON parsing.
45
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
JsonPointer
• IETF RFC 6901
• String syntax for identifying a specific value
– /phone/mobile
– /parents/0
• Special characters
– "/" —> "~1"
– "~" —> "~0"
46
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
JSON Pointer Sample
JsonArray jasons = . . .;
JsonPointer pointer =
Json.createPointer("/1/profession");
JsonValue profession =
pointer.getValue(jasons);
pointer.replace(jasons,
Json.createValue("Super agent"));
47
[
{
"name": "Jason Voorhees",
"profession": "Maniac killer",
"age": 45
},
{
"name": "Jason Bourne",
"profession": "Maniac killer",
"age": 35
}
]
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
JsonPatch
• IETF RFC 6902
• Modify Parts of JSON document
• Patch is a JSON document itself
• Operations:
– Add, replace, remove, move, copy, test
• HTTP PATCH method (application/json-patch+json)
48
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 49
JSON Patch Sample
[
{ "op": "replace",
"path": "/1/profession",
"value": "Super agent" },
{ "op": "remove",
"path": "/2" }
]
[
{
"name": "Jason Voorhees",
"profession": "Maniac killer",
"age": 45
},
{
"name": "Jason Bourne",
"profession": "Maniac killer",
"age": 35
},
{
"name": "James Bond",
"profession": "Agent 007",
"age": 40
}
]
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 50
JSON Patch Sample
[
{ "op": "replace",
"path": "/1/profession",
"value": "Super agent" },
{ "op": "remove",
"path": "/2" }
]
[
{
"name": "Jason Voorhees",
"profession": "Maniac killer",
"age": 45
},
{
"name": "Jason Bourne",
"profession": "Super agent",
"age": 35
},
{
"name": "James Bond",
"profession": "Agent 007",
"age": 40
}
]
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 51
JSON Patch Sample
[
{ "op": "replace",
"path": "/1/profession",
"value": "Super agent" },
{ "op": "remove",
"path": "/2" }
]
[
{
"name": "Jason Voorhees",
"profession": "Maniac killer",
"age": 45
},
{
"name": "Jason Bourne",
"profession": "Super agent",
"age": 35
}
]
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
JSON Binding / Yasson
52
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
• JSON-B (JSON Binding)
– API and Specification
– JSR-367
– Part of Java EE 8
53
JSON-B and Yasson
• Yasson
– Reference Implementation
– Eclipse Foundation Project
– Part of GlassFish 5
– Used by WAS Liberty
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Links
• JSON-B web site
– Official web: http://json-b.net
– GitHub repo: https://github.com/javaee/jsonb-spec
– JCP page: https://www.jcp.org/en/jsr/detail?id=367
– Groups: https://javaee.groups.io/g/jsonb-spec
• Yasson
– Web site: https://projects.eclipse.org/projects/rt.yasson
– GitHub repo: https://github.com/eclipse/yasson
54
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Maven Dependencies
55
<!-- JSON-B API -->
<dependency>
<groupId>javax.json.bind</groupId>
<artifactId>javax.json.bind-api</artifactId>
<version>1.0</version>
</dependency>
<!-- Yasson (JSON-B RI) -->
<dependency>
<groupId>org.eclipse</groupId>
<artifactId>yasson</artifactId>
<version>1.0</version>
</dependency>
<repositories>
<repository>
<id>Yasson Snapshots</id>
<url>https://repo.eclipse.org/content/repositories/
yasson-snapshots/</url>
</repository>
</repositories>
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
JSON Binding
• API to serialize/deserialize Java objects to/from JSON documents
– Similar to JAX-B
– Standardizes the current technologies (Jackson, Genson, Gson)
• Default mapping between classes and JSON
• Customization APIs
– Annotations (@JsonbProperty, @JsonbNillable)
– Runtime configuration builder
• Natural follow on to JSON-P
– Closes the JSON support gap
– Allows to change providers
56
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
• No configuration, no annotations
• The scope:
– Basic Types
– Specific JDK Types
– Dates
– Classes
– Collections/Arrays
– Enumerations
– JSON-P
57
Default Mapping
import javax.json.bind.Jsonb;
import javax.json.bind.JsonbBuilder;
// Create with default config
Jsonb jsonb = JsonbBuilder.create();
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 58
JSON-B Engine
public interface Jsonb extends AutoCloseable {
<T> T fromJson(String str, Class<T> type);
<T> T fromJson(String str, Type runtimeType);
<T> T fromJson(Reader reader, Class<T> type);
<T> T fromJson(Reader reader, Type runtimeType);
<T> T fromJson(InputStream stream, Class<T> type);
<T> T fromJson(InputStream stream, Type runtimeType);
String toJson(Object object);
String toJson(Object object, Type runtimeType);
void toJson(Object object, Writer writer);
void toJson(Object object, Type runtimeType, Writer writer);
void toJson(Object object, OutputStream stream);
void toJson(Object object, Type runtimeType, OutputStream stream);
}
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
JSON-B Sample
59
Person person1 = new Person();
person1.setName("Jason Voorhees");
person1.setProfession("Maniac killer");
person1.setAge(45);
Person person2 = new Person();
person2.setName("Jason Bourne");
person2.setProfession("Super agent");
person2.setAge(35);
List<Person> persons = new ArrayList<>();
persons.add(person1);
persons.add(person2);
Jsonb jsonb = JsonbBuilder.create();
jsonb.toJson(persons);
[
{
"name": "Jason Voorhees",
"profession": "Maniac killer",
"age": 45
},
{
"name": "Jason Bourne",
"profession": "Super agent",
"age": 35
}
]
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Basic Types
– java.lang.String
– java.lang.Character
– java.lang.Byte (byte)
– java.lang.Short (short)
– java.lang.Integer (int)
– java.lang.Long (long)
– java.lang.Float (float)
– java.lang.Double (double)
– java.lang.Boolean (boolean)
Specific Types
– java.math.BigInteger
– java.math.BigDecimal
– java.net.URL
– java.net.URI
– java.util.Optional
– java.util.OptionalInt
– java.util.OptionalLong
– java.util.OptionalDouble
60
Basic and Specific Types
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Date/Time
61
java.util.Date ISO_DATE_TIME
java.util.Calendar, java.util.GregorianCalendar ISO_DATE if to time information present, otherwise ISO_DATE_TIME
Java.util.TimeZone, java.util.SimpleTimeZone NormalizedCustomId (see TimeZone javadoc)
java.time.Instant ISO_INSTANT
java.time.LocalDate ISO_LOCAL_DATE
java.time.LocalTime ISO_LOCAL_TIME
java.time.LocalDateTime ISO_LOCAL_DATE_TIME
java.time.ZonedDateTime ISO_ZONED_DATE_TIME
java.time.OffsetDateTime ISO_OFFSET_DATE_TIME
java.time.OffsetTime ISO_OFFSET_TIME
java.time.ZoneId NormalizedZoneId as specified in ZoneId javadoc
java.time.ZoneOffset NormalizedZoneId as specified in ZoneOffset javadoc
java.time.Duration ISO 8601 seconds based representation
java.time.Period ISO 8601 period representation
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Date/Time Samples
62
// java.util.Date
SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy");
Date parsedDate = sdf.parse("15.11.2016");
jsonb.toJson(parsedDate)); // ”2016-11-15T00:00:00"
// java.util.Calendar
Calendar dateCalendar = Calendar.getInstance();
dateCalendar.clear();
dateCalendar.set(2016, 11, 15);
jsonb.toJson(dateCalendar); // ”2016-11-15”
// java.time.Instant
jsonb.toJson(Instant.parse("2016-11-15T23:00:00Z")); // ”2016-11-15T23:00:00Z”
// java.time.Duration
jsonb.toJson(Duration.ofHours(5).plusMinutes(4)); // “PT5H4M"
// java.time.Period
jsonb.toJson(Period.between(
LocalDate.of(1960, Month.JANUARY, 1),
LocalDate.of(1970, Month.JANUARY, 1))); // "P10Y"
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Arrays/Collections
• Collection
• Map
• Set
• HashSet
• NavigableSet
• SortedSet
• TreeSet
• LinkedHashSet
• HashMap
• NavigableMap
• SortedMap
• TreeMap
• LinkedHashMap
• List
• ArrayList
• LinkedList
• Deque
• ArrayDeque
• Queue
• PriorityQueue
63
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
• javax.json.JsonArray
• javax.json.JsonStructure
• javax.json.JsonValue
• javax.json.JsonPointer
• javax.json.JsonString
• javax.json.JsonNumber
• javax.json.JsonObject
64
JSON-P Types
// JsonObject
JsonBuilderFactory f =
Json.createBuilderFactory(null);
JsonObject jsonObject =
f.createObjectBuilder()
.add(“name", "Jason Bourne")
.add(“city", "Prague")
.build();
jsonb.toJson(jsonObject);
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Classes
• Public and protected nested and static nested classes
• Anonymous classes (serialization only)
• Inheritance is supported
• Default no-argument constructor is required for deserialization
65
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Fields
• Final fields are serialized
• Static fields are skipped
• Transient fields are skipped
• Null fields are skipped
• Fields order
– Lexicographical order
– Parent class fields are serialized before child class fields
66
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
public class Parent {
public int parentB;
public int parentA;
}
{
"parentA": 1,
"parentB": 2
}
67
Fields Order Sample
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
public class Parent {
public int parentB;
public int parentA;
}
public class Child extends Parent {
public int childB;
public int childA;
}
{
"parentA": 1,
"parentB": 2
}
{
"parentA": 1,
"parentB": 2,
"childA": 3,
"childB": 4
}
68
Fields Order Sample
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Serialization
• Existing fields with public getters
• Public fields with no getters
• Public getter/setter pair without a
corresponding field
Deserialization
• Existing fields with public setters
• Public fields with no setters
• Public getter/setter pair without a
corresponding field
69
Scope and Field Access Strategy
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
public class Foo {
public final int publicFinalField;
private final int privateFinalField;
public static int publicStaticField;
public int publicWithNoGetter;
public int publicWithPrivateGetter;
public Integer publicNullField = null;
private int privateWithNoGetter;
private int privateWithPublicGetter;
public int getNoField() {};
public void setNoField(int value) {};
}
{
"publicFinalField": 1,
"publicWithNoGetter": 1,
"privateWithPublicGetter": 1,
"noField": 1
}
70
Scope and Field Access Strategy
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
• Annotations
• Runtime configuration
– JsonbConfig
– JsonbBuilder
71
JSON-B Engine Configuration
JsonbConfig config = new JsonbConfig()
.withFormatting(…)
.withNullValues(…)
.withEncoding(…)
.withStrictIJSON(…)
.withPropertyNamingStrategy(…)
.withPropertyOrderStrategy(…)
.withPropertyVisibilityStrategy(…)
.withAdapters(…)
.withBinaryDataStrategy(…);
Jsonb jsonb = JsonbBuilder.newBuilder()
.withConfig(…)
.withProvider(…)
.build();
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 72
Customizations
• Property names
• Property order
• Ignoring properties
• Null handling
• Custom instantiation
• Fields visibility
• Date/Number Formats
• Binary Encoding
• Adapters
• Serializers/Deserializers
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
• Annotation
– @JsonbProperty
• Scope:
– Field
– Getter/Setter
– Parameter
73
Property Names
public class Customer {
private int id;
@JsonbProperty("name")
public String firstName;
}
public class Customer {
public int id;
public String firstName;
@JsonbProperty("name")
public String getFirstName() {
return firstName;
}
}
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Property Naming Strategy
• Supported naming strategies
– IDENTITY (myMixedCaseProperty)
– LOWER_CASE_WITH_DASHES (my-mixed-case-property)
– LOWER_CASE_WITH_UNDERSCORES (my_mixed_case_property)
– UPPER_CAMEL_CASE (MyMixedCaseProperty)
– UPPER_CAMEL_CASE_WITH_SPACES (My Mixed Case Property)
– CASE_INSENSITIVE (mYmIxEdCaSePrOpErTy)
– Or a custom implementation
• JsonbConfig
– withPropertyNamingStrategy(…):
74
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
• Strategies:
– LEXICOGRAPHICAL (A-Z)
– ANY
– REVERSE (Z-A)
• Annotation
– @JsonbPropertyOrder on class
• JsonbConfig
– withPropertyOrderStrategy(…)
75
Property Order Strategy
@JsonbPropertyOrder(ANY)
public class Foo {
public int bar2;
public int bar1;
}
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
• Annotation
– @JsonbTransient
76
Ignoring Properties
public class Customer {
public int id;
public String name;
@JsonbTransient
public BigDecimal salary;
}
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
• PropertyVisibilityStrategy
interface
• Annotation
– @JsonbVisibility
• JsonbConfig
– withPropertyVisibilityStrategy(…)
77
Property Visibility
public interface PropertyVisibilityStrategy {
boolean isVisible(Field field);
boolean isVisible(Method method);
}
public class MyStrategy implements
PropertyVisibilityStrategy {
/* ... */
}
@JsonbVisibility(MyStrategy.class)
public class Bar {
private int field1;
private int field2;
}
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
• Null fields are skipped by default
• Annotation
– @JsonbNillable
• JsonbConfig
– withNullValues(true)
78
Null Handling
public class Customer {
public int id = 1;
@JsonbProperty("name", true)
public String name = null;
}
@JsonbNillable
public class Customer {
public int id = 1;
public String name = null;
}
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Custom Instantiation
79
public class Customer {
public int id;
public String name;
@JsonbCreator
public static Customer create(
@JsonbProperty("id") int id) {
return CustomerDao.getByPrimaryKey(id);
}
}
public class Order {
public int id;
public Customer customer;
}
{
"id": 123,
"customer": {
"id": 562,
}
}
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
• Annotations
– @JsonbDateFormat
– @JsonbNumberFormat
• JsonbConfig
– withDateFormat(…)
– withLocale(…)
80
Date/Number Format
public class FormatSample {
public Date defaultDate;
@JsonbDateFormat("dd.MM.yyyy")
public Date formattedDate;
public BigDecimal defaultNumber;
@JsonbNumberFormat(“#0.00")
public BigDecimal formattedNumber;
}
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
• Supported encodings
– BYTE (default)
– BASE_64
– BASE_64_URL
• JsonbConfig
– withBinaryDataStrategy(…)
81
Binary Data Encoding
JsonbConfig config = new JsonbConfig()
.withBinaryDataStrategy(
BinaryDataStrategy.BASE_64);
Jsonb jsonb = JsonbBuilder.create(config);
String json = jsonb.toJson(obj);
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
I-JSON
• I-JSON (”Internet JSON”) is a restricted profile of JSON
– https://tools.ietf.org/html/draft-ietf-json-i-json-06
• JSON-B fully supports I-JSON by default with three exceptions:
– JSON Binding does not restrict the serialization of top-level JSON texts that are
neither objects nor arrays. The restriction should happen at application level.
– JSON Binding does not serialize binary data with base64url encoding.
– JSON Binding does not enforce additional restrictions on dates/times/duration.
• JsonbConfig
– withStrictIJSON(true)
82
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
• Inspired by JAXB
• Annotations
– @JsonbTypeAdapter annotation
• JsonbConfig
– withAdapters(…)
83
Adapters
public interface JsonbAdapter<Original, Adapted> {
Adapted adaptToJson(Original obj);
Original adaptFromJson(Adapted obj);
}
@JsonbTypeAdapter(AnimalAdapter.class)
public Animal animal;
JsonbConfig config = new JsonbConfig()
.withAdapters(new AnimalAdapter());
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
• Low level control on
serialization/deserialization
• Annotations
– @JsonbTypeSerializer
– @JsonbTypeDeserializer
• JsonbConfig
– withSerializers(…)
– withDeserializers(…)
84
Serializers/Deserializers
public interface JsonbSerializer<T> {
void serialize(T obj, JsonGenerator generator,
SerializationContext ctx);
public interface JsonbDeserializer<T> {
T deserialize(JsonParser parser,
DeserializationContext ctx, Type rtType);
}
@JsonbTypeSerializer(AnimalSerializer.class)
@JsonbTypeDeserializer(AnimalDeserializer.class)
public Animal animal;
JsonbConfig config = new JsonbConfig()
.withSerializers(new AnimalSerializer())
.withDeserializers(new AnimalDeserializer());
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
JSON-B Demo
• GitHub
– https://github.com/m0mus/json_demo
• Demonstrates
– JSON-P
• JsonParser
• JsonGenerator
• Working with large files
• JsonPointer
• JsonPatch
• Using Java8 streams
85
– JSON-B
• Default mapping
• Adapters
• Serializers/Deserializers
• Mapping of generic class
• Using together with JSON-P
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Q & A
86
JSON Support in Java EE 8

More Related Content

What's hot

How to insert json data into my sql using php
How to insert json data into my sql using phpHow to insert json data into my sql using php
How to insert json data into my sql using php
Trà Minh
 
Java Script Object Notation (JSON)
Java Script Object Notation (JSON)Java Script Object Notation (JSON)
Java Script Object Notation (JSON)
Adnan Sohail
 
Hands on JSON
Hands on JSONHands on JSON
Hands on JSON
Octavian Nadolu
 
Json
JsonJson
Json
soumya
 
Harnessing The Power of Search - Liferay DEVCON 2015, Darmstadt, Germany
Harnessing The Power of Search - Liferay DEVCON 2015, Darmstadt, GermanyHarnessing The Power of Search - Liferay DEVCON 2015, Darmstadt, Germany
Harnessing The Power of Search - Liferay DEVCON 2015, Darmstadt, Germany
André Ricardo Barreto de Oliveira
 
J s-o-n-120219575328402-3
J s-o-n-120219575328402-3J s-o-n-120219575328402-3
J s-o-n-120219575328402-3
Ramamohan Chokkam
 
JSON(JavaScript Object Notation)
JSON(JavaScript Object Notation)JSON(JavaScript Object Notation)
JSON(JavaScript Object Notation)
Raghu nath
 
Json
JsonJson
Liferay Search: Best Practices to Dramatically Improve Relevance - Liferay Sy...
Liferay Search: Best Practices to Dramatically Improve Relevance - Liferay Sy...Liferay Search: Best Practices to Dramatically Improve Relevance - Liferay Sy...
Liferay Search: Best Practices to Dramatically Improve Relevance - Liferay Sy...
André Ricardo Barreto de Oliveira
 
d3sparql.js demo at SWAT4LS 2014 in Berlin
d3sparql.js demo at SWAT4LS 2014 in Berlind3sparql.js demo at SWAT4LS 2014 in Berlin
d3sparql.js demo at SWAT4LS 2014 in Berlin
Toshiaki Katayama
 
An Introduction to JSON JavaScript Object Notation
An Introduction to JSON JavaScript Object NotationAn Introduction to JSON JavaScript Object Notation
An Introduction to JSON JavaScript Object Notation
Ahmed Muzammil
 
Schema design
Schema designSchema design
Schema design
MongoDB
 
Understanding N1QL Optimizer to Tune Queries
Understanding N1QL Optimizer to Tune QueriesUnderstanding N1QL Optimizer to Tune Queries
Understanding N1QL Optimizer to Tune Queries
Keshav Murthy
 

What's hot (13)

How to insert json data into my sql using php
How to insert json data into my sql using phpHow to insert json data into my sql using php
How to insert json data into my sql using php
 
Java Script Object Notation (JSON)
Java Script Object Notation (JSON)Java Script Object Notation (JSON)
Java Script Object Notation (JSON)
 
Hands on JSON
Hands on JSONHands on JSON
Hands on JSON
 
Json
JsonJson
Json
 
Harnessing The Power of Search - Liferay DEVCON 2015, Darmstadt, Germany
Harnessing The Power of Search - Liferay DEVCON 2015, Darmstadt, GermanyHarnessing The Power of Search - Liferay DEVCON 2015, Darmstadt, Germany
Harnessing The Power of Search - Liferay DEVCON 2015, Darmstadt, Germany
 
J s-o-n-120219575328402-3
J s-o-n-120219575328402-3J s-o-n-120219575328402-3
J s-o-n-120219575328402-3
 
JSON(JavaScript Object Notation)
JSON(JavaScript Object Notation)JSON(JavaScript Object Notation)
JSON(JavaScript Object Notation)
 
Json
JsonJson
Json
 
Liferay Search: Best Practices to Dramatically Improve Relevance - Liferay Sy...
Liferay Search: Best Practices to Dramatically Improve Relevance - Liferay Sy...Liferay Search: Best Practices to Dramatically Improve Relevance - Liferay Sy...
Liferay Search: Best Practices to Dramatically Improve Relevance - Liferay Sy...
 
d3sparql.js demo at SWAT4LS 2014 in Berlin
d3sparql.js demo at SWAT4LS 2014 in Berlind3sparql.js demo at SWAT4LS 2014 in Berlin
d3sparql.js demo at SWAT4LS 2014 in Berlin
 
An Introduction to JSON JavaScript Object Notation
An Introduction to JSON JavaScript Object NotationAn Introduction to JSON JavaScript Object Notation
An Introduction to JSON JavaScript Object Notation
 
Schema design
Schema designSchema design
Schema design
 
Understanding N1QL Optimizer to Tune Queries
Understanding N1QL Optimizer to Tune QueriesUnderstanding N1QL Optimizer to Tune Queries
Understanding N1QL Optimizer to Tune Queries
 

Similar to JSON Support in Java EE 8

JSON Support in Java EE 8
JSON Support in Java EE 8JSON Support in Java EE 8
JSON Support in Java EE 8
Dmitry Kornilov
 
Java EE 7 overview
Java EE 7 overviewJava EE 7 overview
Java EE 7 overview
Masoud Kalali
 
Making Sense of Schema on Read
Making Sense of Schema on ReadMaking Sense of Schema on Read
Making Sense of Schema on Read
Kent Graziano
 
JSON support in Java EE 8
JSON support in Java EE 8JSON support in Java EE 8
JSON support in Java EE 8
Lukas Jungmann
 
JSON and the Oracle Database
JSON and the Oracle DatabaseJSON and the Oracle Database
JSON and the Oracle Database
Maria Colgan
 
ABD338_MirrorWeb - Powering Large-scale, Full-text Search for the UK Governme...
ABD338_MirrorWeb - Powering Large-scale, Full-text Search for the UK Governme...ABD338_MirrorWeb - Powering Large-scale, Full-text Search for the UK Governme...
ABD338_MirrorWeb - Powering Large-scale, Full-text Search for the UK Governme...
Amazon Web Services
 
Java EE 8 - An instant snapshot
Java EE 8 - An instant snapshotJava EE 8 - An instant snapshot
Java EE 8 - An instant snapshot
David Delabassee
 
Json at work overview and ecosystem-v2.0
Json at work   overview and ecosystem-v2.0Json at work   overview and ecosystem-v2.0
Json at work overview and ecosystem-v2.0
Boulder Java User's Group
 
Advanced Json
Advanced JsonAdvanced Json
Advanced Json
guestfd7d7c
 
Java Script Based Client Server Webapps 2
Java Script Based Client Server Webapps 2Java Script Based Client Server Webapps 2
Java Script Based Client Server Webapps 2
kriszyp
 
Do More with Postgres- NoSQL Applications for the Enterprise
Do More with Postgres- NoSQL Applications for the EnterpriseDo More with Postgres- NoSQL Applications for the Enterprise
Do More with Postgres- NoSQL Applications for the Enterprise
EDB
 
PGQL: A Language for Graphs
PGQL: A Language for GraphsPGQL: A Language for Graphs
PGQL: A Language for Graphs
Jean Ihm
 
Java API for JSON Binding - Introduction and update
Java API for JSON Binding - Introduction and updateJava API for JSON Binding - Introduction and update
Java API for JSON Binding - Introduction and update
Martin Grebac
 
Java EE 8 Overview (Japanese)
Java EE 8 Overview (Japanese)Java EE 8 Overview (Japanese)
Java EE 8 Overview (Japanese)
Logico
 
Python and the MySQL Document Store
Python and the MySQL Document StorePython and the MySQL Document Store
Python and the MySQL Document Store
Jesper Wisborg Krogh
 
What's coming in Java EE 8
What's coming in Java EE 8What's coming in Java EE 8
What's coming in Java EE 8
David Delabassee
 
LF_APIStrat17_Embracing JSON Schema
LF_APIStrat17_Embracing JSON SchemaLF_APIStrat17_Embracing JSON Schema
LF_APIStrat17_Embracing JSON Schema
LF_APIStrat
 
The NoSQL Way in Postgres
The NoSQL Way in PostgresThe NoSQL Way in Postgres
The NoSQL Way in Postgres
EDB
 
JavaCro'15 - Java EE 8 - An instant snapshot - David Delabassee
JavaCro'15 - Java EE 8 - An instant snapshot - David DelabasseeJavaCro'15 - Java EE 8 - An instant snapshot - David Delabassee
JavaCro'15 - Java EE 8 - An instant snapshot - David Delabassee
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
How to Hack Your App Using SQL Injection
How to Hack Your App Using SQL InjectionHow to Hack Your App Using SQL Injection
How to Hack Your App Using SQL Injection
Chris Saxon
 

Similar to JSON Support in Java EE 8 (20)

JSON Support in Java EE 8
JSON Support in Java EE 8JSON Support in Java EE 8
JSON Support in Java EE 8
 
Java EE 7 overview
Java EE 7 overviewJava EE 7 overview
Java EE 7 overview
 
Making Sense of Schema on Read
Making Sense of Schema on ReadMaking Sense of Schema on Read
Making Sense of Schema on Read
 
JSON support in Java EE 8
JSON support in Java EE 8JSON support in Java EE 8
JSON support in Java EE 8
 
JSON and the Oracle Database
JSON and the Oracle DatabaseJSON and the Oracle Database
JSON and the Oracle Database
 
ABD338_MirrorWeb - Powering Large-scale, Full-text Search for the UK Governme...
ABD338_MirrorWeb - Powering Large-scale, Full-text Search for the UK Governme...ABD338_MirrorWeb - Powering Large-scale, Full-text Search for the UK Governme...
ABD338_MirrorWeb - Powering Large-scale, Full-text Search for the UK Governme...
 
Java EE 8 - An instant snapshot
Java EE 8 - An instant snapshotJava EE 8 - An instant snapshot
Java EE 8 - An instant snapshot
 
Json at work overview and ecosystem-v2.0
Json at work   overview and ecosystem-v2.0Json at work   overview and ecosystem-v2.0
Json at work overview and ecosystem-v2.0
 
Advanced Json
Advanced JsonAdvanced Json
Advanced Json
 
Java Script Based Client Server Webapps 2
Java Script Based Client Server Webapps 2Java Script Based Client Server Webapps 2
Java Script Based Client Server Webapps 2
 
Do More with Postgres- NoSQL Applications for the Enterprise
Do More with Postgres- NoSQL Applications for the EnterpriseDo More with Postgres- NoSQL Applications for the Enterprise
Do More with Postgres- NoSQL Applications for the Enterprise
 
PGQL: A Language for Graphs
PGQL: A Language for GraphsPGQL: A Language for Graphs
PGQL: A Language for Graphs
 
Java API for JSON Binding - Introduction and update
Java API for JSON Binding - Introduction and updateJava API for JSON Binding - Introduction and update
Java API for JSON Binding - Introduction and update
 
Java EE 8 Overview (Japanese)
Java EE 8 Overview (Japanese)Java EE 8 Overview (Japanese)
Java EE 8 Overview (Japanese)
 
Python and the MySQL Document Store
Python and the MySQL Document StorePython and the MySQL Document Store
Python and the MySQL Document Store
 
What's coming in Java EE 8
What's coming in Java EE 8What's coming in Java EE 8
What's coming in Java EE 8
 
LF_APIStrat17_Embracing JSON Schema
LF_APIStrat17_Embracing JSON SchemaLF_APIStrat17_Embracing JSON Schema
LF_APIStrat17_Embracing JSON Schema
 
The NoSQL Way in Postgres
The NoSQL Way in PostgresThe NoSQL Way in Postgres
The NoSQL Way in Postgres
 
JavaCro'15 - Java EE 8 - An instant snapshot - David Delabassee
JavaCro'15 - Java EE 8 - An instant snapshot - David DelabasseeJavaCro'15 - Java EE 8 - An instant snapshot - David Delabassee
JavaCro'15 - Java EE 8 - An instant snapshot - David Delabassee
 
How to Hack Your App Using SQL Injection
How to Hack Your App Using SQL InjectionHow to Hack Your App Using SQL Injection
How to Hack Your App Using SQL Injection
 

More from Dmitry Kornilov

Helidon Nima - Loom based microserfice framework.pptx
Helidon Nima - Loom based microserfice framework.pptxHelidon Nima - Loom based microserfice framework.pptx
Helidon Nima - Loom based microserfice framework.pptx
Dmitry Kornilov
 
Jakarta EE: Today and Tomorrow
Jakarta EE: Today and TomorrowJakarta EE: Today and Tomorrow
Jakarta EE: Today and Tomorrow
Dmitry Kornilov
 
Building Cloud-Native Applications with Helidon
Building Cloud-Native Applications with HelidonBuilding Cloud-Native Applications with Helidon
Building Cloud-Native Applications with Helidon
Dmitry Kornilov
 
Nonblocking Database Access in Helidon SE
Nonblocking Database Access in Helidon SENonblocking Database Access in Helidon SE
Nonblocking Database Access in Helidon SE
Dmitry Kornilov
 
JSON Support in Jakarta EE: Present and Future
JSON Support in Jakarta EE: Present and FutureJSON Support in Jakarta EE: Present and Future
JSON Support in Jakarta EE: Present and Future
Dmitry Kornilov
 
Building cloud native microservices with project Helidon
Building cloud native microservices with project HelidonBuilding cloud native microservices with project Helidon
Building cloud native microservices with project Helidon
Dmitry Kornilov
 
Developing cloud-native microservices using project Helidon
Developing cloud-native microservices using project HelidonDeveloping cloud-native microservices using project Helidon
Developing cloud-native microservices using project Helidon
Dmitry Kornilov
 
From Java EE to Jakarta EE
From Java EE to Jakarta EEFrom Java EE to Jakarta EE
From Java EE to Jakarta EE
Dmitry Kornilov
 
Helidon: Java Libraries for Writing Microservices
Helidon: Java Libraries for Writing MicroservicesHelidon: Java Libraries for Writing Microservices
Helidon: Java Libraries for Writing Microservices
Dmitry Kornilov
 
Adopt-a-JSR session (JSON-B/P)
Adopt-a-JSR session (JSON-B/P)Adopt-a-JSR session (JSON-B/P)
Adopt-a-JSR session (JSON-B/P)
Dmitry Kornilov
 
Configuration for Java EE: Config JSR and Tamaya
Configuration for Java EE: Config JSR and TamayaConfiguration for Java EE: Config JSR and Tamaya
Configuration for Java EE: Config JSR and Tamaya
Dmitry Kornilov
 
Java EE for the Cloud
Java EE for the CloudJava EE for the Cloud
Java EE for the Cloud
Dmitry Kornilov
 
Configuration for Java EE and the Cloud
Configuration for Java EE and the CloudConfiguration for Java EE and the Cloud
Configuration for Java EE and the Cloud
Dmitry Kornilov
 
What's new in the Java API for JSON Binding
What's new in the Java API for JSON BindingWhat's new in the Java API for JSON Binding
What's new in the Java API for JSON Binding
Dmitry Kornilov
 
JSON-B for CZJUG
JSON-B for CZJUGJSON-B for CZJUG
JSON-B for CZJUG
Dmitry Kornilov
 
JSONB introduction and comparison with other frameworks
JSONB introduction and comparison with other frameworksJSONB introduction and comparison with other frameworks
JSONB introduction and comparison with other frameworks
Dmitry Kornilov
 
What’s new in JSR 367 Java API for JSON Binding
What’s new in JSR 367 Java API for JSON BindingWhat’s new in JSR 367 Java API for JSON Binding
What’s new in JSR 367 Java API for JSON Binding
Dmitry Kornilov
 

More from Dmitry Kornilov (17)

Helidon Nima - Loom based microserfice framework.pptx
Helidon Nima - Loom based microserfice framework.pptxHelidon Nima - Loom based microserfice framework.pptx
Helidon Nima - Loom based microserfice framework.pptx
 
Jakarta EE: Today and Tomorrow
Jakarta EE: Today and TomorrowJakarta EE: Today and Tomorrow
Jakarta EE: Today and Tomorrow
 
Building Cloud-Native Applications with Helidon
Building Cloud-Native Applications with HelidonBuilding Cloud-Native Applications with Helidon
Building Cloud-Native Applications with Helidon
 
Nonblocking Database Access in Helidon SE
Nonblocking Database Access in Helidon SENonblocking Database Access in Helidon SE
Nonblocking Database Access in Helidon SE
 
JSON Support in Jakarta EE: Present and Future
JSON Support in Jakarta EE: Present and FutureJSON Support in Jakarta EE: Present and Future
JSON Support in Jakarta EE: Present and Future
 
Building cloud native microservices with project Helidon
Building cloud native microservices with project HelidonBuilding cloud native microservices with project Helidon
Building cloud native microservices with project Helidon
 
Developing cloud-native microservices using project Helidon
Developing cloud-native microservices using project HelidonDeveloping cloud-native microservices using project Helidon
Developing cloud-native microservices using project Helidon
 
From Java EE to Jakarta EE
From Java EE to Jakarta EEFrom Java EE to Jakarta EE
From Java EE to Jakarta EE
 
Helidon: Java Libraries for Writing Microservices
Helidon: Java Libraries for Writing MicroservicesHelidon: Java Libraries for Writing Microservices
Helidon: Java Libraries for Writing Microservices
 
Adopt-a-JSR session (JSON-B/P)
Adopt-a-JSR session (JSON-B/P)Adopt-a-JSR session (JSON-B/P)
Adopt-a-JSR session (JSON-B/P)
 
Configuration for Java EE: Config JSR and Tamaya
Configuration for Java EE: Config JSR and TamayaConfiguration for Java EE: Config JSR and Tamaya
Configuration for Java EE: Config JSR and Tamaya
 
Java EE for the Cloud
Java EE for the CloudJava EE for the Cloud
Java EE for the Cloud
 
Configuration for Java EE and the Cloud
Configuration for Java EE and the CloudConfiguration for Java EE and the Cloud
Configuration for Java EE and the Cloud
 
What's new in the Java API for JSON Binding
What's new in the Java API for JSON BindingWhat's new in the Java API for JSON Binding
What's new in the Java API for JSON Binding
 
JSON-B for CZJUG
JSON-B for CZJUGJSON-B for CZJUG
JSON-B for CZJUG
 
JSONB introduction and comparison with other frameworks
JSONB introduction and comparison with other frameworksJSONB introduction and comparison with other frameworks
JSONB introduction and comparison with other frameworks
 
What’s new in JSR 367 Java API for JSON Binding
What’s new in JSR 367 Java API for JSON BindingWhat’s new in JSR 367 Java API for JSON Binding
What’s new in JSR 367 Java API for JSON Binding
 

Recently uploaded

Oracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptxOracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptx
Remote DBA Services
 
Migration From CH 1.0 to CH 2.0 and Mule 4.6 & Java 17 Upgrade.pptx
Migration From CH 1.0 to CH 2.0 and  Mule 4.6 & Java 17 Upgrade.pptxMigration From CH 1.0 to CH 2.0 and  Mule 4.6 & Java 17 Upgrade.pptx
Migration From CH 1.0 to CH 2.0 and Mule 4.6 & Java 17 Upgrade.pptx
ervikas4
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
Peter Muessig
 
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
gapen1
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
Drona Infotech
 
ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.
Maitrey Patel
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
XfilesPro
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
ICS
 
How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
ToXSL Technologies
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
Remote DBA Services
 
The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...
The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...
The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...
kalichargn70th171
 
All you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVMAll you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVM
Alina Yurenko
 
WWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders AustinWWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders Austin
Patrick Weigel
 
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSISDECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
Tier1 app
 
Preparing Non - Technical Founders for Engaging a Tech Agency
Preparing Non - Technical Founders for Engaging  a  Tech AgencyPreparing Non - Technical Founders for Engaging  a  Tech Agency
Preparing Non - Technical Founders for Engaging a Tech Agency
ISH Technologies
 
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdfBaha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
Baha Majid
 
Enhanced Screen Flows UI/UX using SLDS with Tom Kitt
Enhanced Screen Flows UI/UX using SLDS with Tom KittEnhanced Screen Flows UI/UX using SLDS with Tom Kitt
Enhanced Screen Flows UI/UX using SLDS with Tom Kitt
Peter Caitens
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
rodomar2
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
brainerhub1
 
Project Management: The Role of Project Dashboards.pdf
Project Management: The Role of Project Dashboards.pdfProject Management: The Role of Project Dashboards.pdf
Project Management: The Role of Project Dashboards.pdf
Karya Keeper
 

Recently uploaded (20)

Oracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptxOracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptx
 
Migration From CH 1.0 to CH 2.0 and Mule 4.6 & Java 17 Upgrade.pptx
Migration From CH 1.0 to CH 2.0 and  Mule 4.6 & Java 17 Upgrade.pptxMigration From CH 1.0 to CH 2.0 and  Mule 4.6 & Java 17 Upgrade.pptx
Migration From CH 1.0 to CH 2.0 and Mule 4.6 & Java 17 Upgrade.pptx
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
 
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
 
ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
 
How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
 
The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...
The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...
The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...
 
All you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVMAll you need to know about Spring Boot and GraalVM
All you need to know about Spring Boot and GraalVM
 
WWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders AustinWWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders Austin
 
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSISDECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
 
Preparing Non - Technical Founders for Engaging a Tech Agency
Preparing Non - Technical Founders for Engaging  a  Tech AgencyPreparing Non - Technical Founders for Engaging  a  Tech Agency
Preparing Non - Technical Founders for Engaging a Tech Agency
 
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdfBaha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
 
Enhanced Screen Flows UI/UX using SLDS with Tom Kitt
Enhanced Screen Flows UI/UX using SLDS with Tom KittEnhanced Screen Flows UI/UX using SLDS with Tom Kitt
Enhanced Screen Flows UI/UX using SLDS with Tom Kitt
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
 
Project Management: The Role of Project Dashboards.pdf
Project Management: The Role of Project Dashboards.pdfProject Management: The Role of Project Dashboards.pdf
Project Management: The Role of Project Dashboards.pdf
 

JSON Support in Java EE 8

  • 1. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. JSON Support in Java EE 8 JSON-P, JSON-B, Yasson Dmitry Kornilov JSONB/P Specifications Lead @m0mus 28 Aug 2017
  • 2. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. Safe Harbor Statement 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 Oracle’s products remains at the sole discretion of Oracle. 2
  • 3. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 3 Dmitry Kornilov • Senior Manager @ Oracle • JSON-B (JSR-367) spec lead • JSON-P (JSR-374) spec lead • Outstanding Spec Lead 2016 • EclipseLink project committer
  • 4. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. Program Agenda Introduction JSON Processing JSON Binding / Yasson Q & A 1 2 3 5 4
  • 5. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. Introduction 5
  • 6. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 6 What is JSON???
  • 7. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. This is Jason 7
  • 8. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. This is also Jason 8
  • 9. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. This is JSON-B 9
  • 10. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. What is JSON? • JavaScript Object Notation • Subset of JavaScript • Lightweight data-interchange format • Object, Array, Value 10 { "name": "Jason Bourne", "age": 35, "phoneNumbers": [ { "type": "home", "number": "123-456-789" } ] }
  • 11. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. JSON Support in Java EE 8 • JSON Processing API – Standard API to parse, generate, transform, query JSON – Object Model and Streaming API • similar to DOM and StAX • JSON Binding API – Binding JSON documents to Java objects • similar to JAXB 11
  • 12. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. JSON Processing 12
  • 13. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. JSON-P Links • JSON-P Public Web Site – https://javaee.github.io/jsonp/ • GitHub – https://github.com/javaee/jsonp • JCP – https://jcp.org/en/jsr/detail?id=374 • Discussion Groups – https://javaee.groups.io/g/jsonp-spec 13
  • 14. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. Maven Dependencies 14 <!-- JSON-P API & RI --> <dependency> <groupId>org.glassfish</groupId> <artifactId>javax.json</artifactId> <version>1.1</version> </dependency> <!-- JSON-P API --> <dependency> <groupId>javax.json</groupId> <artifactId>javax.json-api</artifactId> <version>1.1</version> </dependency>
  • 15. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. JSON-P • Streaming API – JsonParser – JsonGenerator • Object model API – JsonReader – JsonWriter – JsonPointer – JsonPatch – JsonMergePatch 15
  • 16. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. JsonParser • JsonParser – Parses JSON in a streaming way from input sources – Similar to StAX’s XMLStreamReader, a pull parser • Created using: • Json.createParser(…), Json.createParserFactory().createParser(…) • Optionally, configured with features • Parser state events: – START_ARRAY, START_OBJECT, KEY_NAME, VALUE_STRING, VALUE_NUMBER, VALUE_TRUE, VALUE_FALSE, VALUE_NULL, END_OBJECT, END_ARRAY 16
  • 17. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 17 JsonParser { "name": "Jason Bourne", "age": 35, "phoneNumbers": [ { "type": "home", "number": "123-456-789" } ] }
  • 18. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 18 JsonParser START_OBJECT{ "name": "Jason Bourne", "age": 35, "phoneNumbers": [ { "type": "home", "number": "123-456-789" } ] }
  • 19. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 19 JsonParser START_OBJECT KEY_NAME { "name": "Jason Bourne", "age": 35, "phoneNumbers": [ { "type": "home", "number": "123-456-789" } ] }
  • 20. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 20 JsonParser START_OBJECT KEY_NAME VALUE_STRING { "name": "Jason Bourne", "age": 35, "phoneNumbers": [ { "type": "home", "number": "123-456-789" } ] }
  • 21. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 21 JsonParser START_OBJECT KEY_NAME VALUE_STRING KEY_NAME { "name": "Jason Bourne", "age": 35, "phoneNumbers": [ { "type": "home", "number": "123-456-789" } ] }
  • 22. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 22 JsonParser START_OBJECT KEY_NAME VALUE_STRING KEY_NAME VALUE_NUMBER { "name": "Jason Bourne", "age": 35, "phoneNumbers": [ { "type": "home", "number": "123-456-789" } ] }
  • 23. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 23 JsonParser START_OBJECT KEY_NAME VALUE_STRING KEY_NAME VALUE_NUMBER KEY_NAME { "name": "Jason Bourne", "age": 35, "phoneNumbers": [ { "type": "home", "number": "123-456-789" } ] }
  • 24. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 24 JsonParser START_OBJECT KEY_NAME VALUE_STRING KEY_NAME VALUE_NUMBER KEY_NAME START_ARRAY { "name": "Jason Bourne", "age": 35, "phoneNumbers": [ { "type": "home", "number": "123-456-789" } ] }
  • 25. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 25 JsonParser START_OBJECT KEY_NAME VALUE_STRING KEY_NAME VALUE_NUMBER KEY_NAME START_ARRAY START_OBJECT { "name": "Jason Bourne", "age": 35, "phoneNumbers": [ { "type": "home", "number": "123-456-789" } ] }
  • 26. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 26 JsonParser START_OBJECT KEY_NAME VALUE_STRING KEY_NAME VALUE_NUMBER KEY_NAME START_ARRAY START_OBJECT KEY_NAME, VALUE_STRING { "name": "Jason Bourne", "age": 35, "phoneNumbers": [ { "type": "home", "number": "123-456-789" } ] }
  • 27. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 27 JsonParser START_OBJECT KEY_NAME VALUE_STRING KEY_NAME VALUE_NUMBER KEY_NAME START_ARRAY START_OBJECT KEY_NAME, VALUE_STRING KEY_NAME, VALUE_STRING { "name": "Jason Bourne", "age": 35, "phoneNumbers": [ { "type": "home", "number": "123-456-789" } ] }
  • 28. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 28 JsonParser START_OBJECT KEY_NAME VALUE_STRING KEY_NAME VALUE_NUMBER KEY_NAME START_ARRAY START_OBJECT KEY_NAME, VALUE_STRING KEY_NAME, VALUE_STRING END_OBJECT { "name": "Jason Bourne", "age": 35, "phoneNumbers": [ { "type": "home", "number": "123-456-789" } ] }
  • 29. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 29 JsonParser START_OBJECT KEY_NAME VALUE_STRING KEY_NAME VALUE_NUMBER KEY_NAME START_ARRAY START_OBJECT KEY_NAME, VALUE_STRING KEY_NAME, VALUE_STRING END_OBJECT END_ARRAY { "name": "Jason Bourne", "age": 35, "phoneNumbers": [ { "type": "home", "number": "123-456-789" } ] }
  • 30. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 30 JsonParser START_OBJECT KEY_NAME VALUE_STRING KEY_NAME VALUE_NUMBER KEY_NAME START_ARRAY START_OBJECT KEY_NAME, VALUE_STRING KEY_NAME, VALUE_STRING END_OBJECT END_ARRAY END_OBJECT { "name": "Jason Bourne", "age": 35, "phoneNumbers": [ { "type": "home", "number": "123-456-789" } ] }
  • 31. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 31 JsonParser { "name": "Jason Bourne", "age": 35, "phoneNumbers": [ { "type": "home", "number": "123-456-789" } ] } JsonParser parser = Json.createParser(...);
  • 32. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 32 JsonParser { "name": "Jason Bourne", "age": 35, "phoneNumbers": [ { "type": "home", "number": "123-456-789" } ] } JsonParser parser = Json.createParser(...); Event e = parser.next(); // START_OBJECT
  • 33. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 33 JsonParser { "name": "Jason Bourne", "age": 35, "phoneNumbers": [ { "type": "home", "number": "123-456-789" } ] } JsonParser parser = Json.createParser(...); Event e = parser.next(); // START_OBJECT parser.next(); // KEY_NAME
  • 34. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 34 JsonParser { "name": "Jason Bourne", "age": 35, "phoneNumbers": [ { "type": "home", "number": "123-456-789" } ] } JsonParser parser = Json.createParser(...); Event e = parser.next(); // START_OBJECT parser.next(); // KEY_NAME parser.getString(); // name
  • 35. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 35 JsonParser { "name": "Jason Bourne", "age": 35, "phoneNumbers": [ { "type": "home", "number": "123-456-789" } ] } JsonParser parser = Json.createParser(...); Event e = parser.next(); // START_OBJECT parser.next(); // KEY_NAME parser.getString(); // name parser.next(); // VALUE_STRING
  • 36. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 36 JsonParser { "name": "Jason Bourne", "age": 35, "phoneNumbers": [ { "type": "home", "number": "123-456-789" } ] } JsonParser parser = Json.createParser(...); Event e = parser.next(); // START_OBJECT parser.next(); // KEY_NAME parser.getString(); // name parser.next(); // VALUE_STRING parser.getString(); // Jason Bourne
  • 37. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 37 JsonParser { "name": "Jason Bourne", "age": 35, "phoneNumbers": [ { "type": "home", "number": "123-456-789" } ] } JsonParser parser = Json.createParser(...); Event e = parser.next(); // START_OBJECT parser.next(); // KEY_NAME parser.getString(); // name parser.next(); // VALUE_STRING parser.getString(); // Jason Bourne parser.next(); // KEY_NAME
  • 38. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 38 JsonParser { "name": "Jason Bourne", "age": 35, "phoneNumbers": [ { "type": "home", "number": "123-456-789" } ] } JsonParser parser = Json.createParser(...); Event e = parser.next(); // START_OBJECT parser.next(); // KEY_NAME parser.getString(); // name parser.next(); // VALUE_STRING parser.getString(); // Jason Bourne parser.next(); // KEY_NAME parser.getString(); // age
  • 39. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 39 JsonParser { "name": "Jason Bourne", "age": 35, "phoneNumbers": [ { "type": "home", "number": "123-456-789" } ] } JsonParser parser = Json.createParser(...); Event e = parser.next(); // START_OBJECT parser.next(); // KEY_NAME parser.getString(); // name parser.next(); // VALUE_STRING parser.getString(); // Jason Bourne parser.next(); // KEY_NAME parser.getString(); // age parser.next(); // VALUE_NUMBER
  • 40. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 40 JsonParser { "name": "Jason Bourne", "age": 35, "phoneNumbers": [ { "type": "home", "number": "123-456-789" } ] } JsonParser parser = Json.createParser(...); Event e = parser.next(); // START_OBJECT parser.next(); // KEY_NAME parser.getString(); // name parser.next(); // VALUE_STRING parser.getString(); // Jason Bourne parser.next(); // KEY_NAME parser.getString(); // age parser.next(); // VALUE_NUMBER parser.getInt(); // 35
  • 41. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. JsonGenerator • Generates JSON in a streaming way to output sources – Similar to StAX’s XMLStreamWriter • Created using: – Json.createGenerator(…) – Json.createGeneratorFactory().createGenerator(…) • Optionally, configured with features – e.g. pretty printing • Allows method chaining 41
  • 42. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 42 JsonGenerator JsonGenerator ge=Json.createGenerator(…); ge.writeStartArray() .writeStartObject() .write("type", "home”) .write("number", "123-456-789") .writeEnd() .writeStartObject() .write("type", "fax”) .write("number", "123-456-790") .writeEnd() .writeEnd() .close(); [ { "type": "home”, "number": "123-456-789" }, { "type": "fax”, "number": "123-456-790" } ]
  • 43. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. Object Model API • Builder to build JsonObject and JsonArray from scratch • Allows method chaining • Type-safe (cannot mix array and object building methods) • Can also use existing JsonObject and JsonArray in a builder 43
  • 44. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 44 Object Model API JsonArray value = Json.createArrayBuilder() .add(Json.createObjectBuilder() .add("type", "home") .add("number", "123-456-789") .build(); ) .add(Json.createObjectBuilder() .add("type", "fax") .add("number", "123-456-790") .build() ) .build(); [ { "type": "home”, "number": "123-456-789" }, { "type": "fax”, "number": "123-456-790" } ]
  • 45. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. JSON-P 1.1 • Update JSON-P spec to stay current with emerging standards (RFC 7159) • Support for IETF standards on – JSON Pointer (RFC 6901) – JSON Patch (RFC 6902) – JSON Merge Patch (RFC 7396) • Add editing/transformation operations to JSON objects and arrays • Support for a streaming API, together with Collectors • Support for processing big JSON, e.g. add filters to JSON parsing. 45
  • 46. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. JsonPointer • IETF RFC 6901 • String syntax for identifying a specific value – /phone/mobile – /parents/0 • Special characters – "/" —> "~1" – "~" —> "~0" 46
  • 47. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. JSON Pointer Sample JsonArray jasons = . . .; JsonPointer pointer = Json.createPointer("/1/profession"); JsonValue profession = pointer.getValue(jasons); pointer.replace(jasons, Json.createValue("Super agent")); 47 [ { "name": "Jason Voorhees", "profession": "Maniac killer", "age": 45 }, { "name": "Jason Bourne", "profession": "Maniac killer", "age": 35 } ]
  • 48. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. JsonPatch • IETF RFC 6902 • Modify Parts of JSON document • Patch is a JSON document itself • Operations: – Add, replace, remove, move, copy, test • HTTP PATCH method (application/json-patch+json) 48
  • 49. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 49 JSON Patch Sample [ { "op": "replace", "path": "/1/profession", "value": "Super agent" }, { "op": "remove", "path": "/2" } ] [ { "name": "Jason Voorhees", "profession": "Maniac killer", "age": 45 }, { "name": "Jason Bourne", "profession": "Maniac killer", "age": 35 }, { "name": "James Bond", "profession": "Agent 007", "age": 40 } ]
  • 50. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 50 JSON Patch Sample [ { "op": "replace", "path": "/1/profession", "value": "Super agent" }, { "op": "remove", "path": "/2" } ] [ { "name": "Jason Voorhees", "profession": "Maniac killer", "age": 45 }, { "name": "Jason Bourne", "profession": "Super agent", "age": 35 }, { "name": "James Bond", "profession": "Agent 007", "age": 40 } ]
  • 51. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 51 JSON Patch Sample [ { "op": "replace", "path": "/1/profession", "value": "Super agent" }, { "op": "remove", "path": "/2" } ] [ { "name": "Jason Voorhees", "profession": "Maniac killer", "age": 45 }, { "name": "Jason Bourne", "profession": "Super agent", "age": 35 } ]
  • 52. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. JSON Binding / Yasson 52
  • 53. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. • JSON-B (JSON Binding) – API and Specification – JSR-367 – Part of Java EE 8 53 JSON-B and Yasson • Yasson – Reference Implementation – Eclipse Foundation Project – Part of GlassFish 5 – Used by WAS Liberty
  • 54. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. Links • JSON-B web site – Official web: http://json-b.net – GitHub repo: https://github.com/javaee/jsonb-spec – JCP page: https://www.jcp.org/en/jsr/detail?id=367 – Groups: https://javaee.groups.io/g/jsonb-spec • Yasson – Web site: https://projects.eclipse.org/projects/rt.yasson – GitHub repo: https://github.com/eclipse/yasson 54
  • 55. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. Maven Dependencies 55 <!-- JSON-B API --> <dependency> <groupId>javax.json.bind</groupId> <artifactId>javax.json.bind-api</artifactId> <version>1.0</version> </dependency> <!-- Yasson (JSON-B RI) --> <dependency> <groupId>org.eclipse</groupId> <artifactId>yasson</artifactId> <version>1.0</version> </dependency> <repositories> <repository> <id>Yasson Snapshots</id> <url>https://repo.eclipse.org/content/repositories/ yasson-snapshots/</url> </repository> </repositories>
  • 56. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. JSON Binding • API to serialize/deserialize Java objects to/from JSON documents – Similar to JAX-B – Standardizes the current technologies (Jackson, Genson, Gson) • Default mapping between classes and JSON • Customization APIs – Annotations (@JsonbProperty, @JsonbNillable) – Runtime configuration builder • Natural follow on to JSON-P – Closes the JSON support gap – Allows to change providers 56
  • 57. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. • No configuration, no annotations • The scope: – Basic Types – Specific JDK Types – Dates – Classes – Collections/Arrays – Enumerations – JSON-P 57 Default Mapping import javax.json.bind.Jsonb; import javax.json.bind.JsonbBuilder; // Create with default config Jsonb jsonb = JsonbBuilder.create();
  • 58. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 58 JSON-B Engine public interface Jsonb extends AutoCloseable { <T> T fromJson(String str, Class<T> type); <T> T fromJson(String str, Type runtimeType); <T> T fromJson(Reader reader, Class<T> type); <T> T fromJson(Reader reader, Type runtimeType); <T> T fromJson(InputStream stream, Class<T> type); <T> T fromJson(InputStream stream, Type runtimeType); String toJson(Object object); String toJson(Object object, Type runtimeType); void toJson(Object object, Writer writer); void toJson(Object object, Type runtimeType, Writer writer); void toJson(Object object, OutputStream stream); void toJson(Object object, Type runtimeType, OutputStream stream); }
  • 59. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. JSON-B Sample 59 Person person1 = new Person(); person1.setName("Jason Voorhees"); person1.setProfession("Maniac killer"); person1.setAge(45); Person person2 = new Person(); person2.setName("Jason Bourne"); person2.setProfession("Super agent"); person2.setAge(35); List<Person> persons = new ArrayList<>(); persons.add(person1); persons.add(person2); Jsonb jsonb = JsonbBuilder.create(); jsonb.toJson(persons); [ { "name": "Jason Voorhees", "profession": "Maniac killer", "age": 45 }, { "name": "Jason Bourne", "profession": "Super agent", "age": 35 } ]
  • 60. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. Basic Types – java.lang.String – java.lang.Character – java.lang.Byte (byte) – java.lang.Short (short) – java.lang.Integer (int) – java.lang.Long (long) – java.lang.Float (float) – java.lang.Double (double) – java.lang.Boolean (boolean) Specific Types – java.math.BigInteger – java.math.BigDecimal – java.net.URL – java.net.URI – java.util.Optional – java.util.OptionalInt – java.util.OptionalLong – java.util.OptionalDouble 60 Basic and Specific Types
  • 61. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. Date/Time 61 java.util.Date ISO_DATE_TIME java.util.Calendar, java.util.GregorianCalendar ISO_DATE if to time information present, otherwise ISO_DATE_TIME Java.util.TimeZone, java.util.SimpleTimeZone NormalizedCustomId (see TimeZone javadoc) java.time.Instant ISO_INSTANT java.time.LocalDate ISO_LOCAL_DATE java.time.LocalTime ISO_LOCAL_TIME java.time.LocalDateTime ISO_LOCAL_DATE_TIME java.time.ZonedDateTime ISO_ZONED_DATE_TIME java.time.OffsetDateTime ISO_OFFSET_DATE_TIME java.time.OffsetTime ISO_OFFSET_TIME java.time.ZoneId NormalizedZoneId as specified in ZoneId javadoc java.time.ZoneOffset NormalizedZoneId as specified in ZoneOffset javadoc java.time.Duration ISO 8601 seconds based representation java.time.Period ISO 8601 period representation
  • 62. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. Date/Time Samples 62 // java.util.Date SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy"); Date parsedDate = sdf.parse("15.11.2016"); jsonb.toJson(parsedDate)); // ”2016-11-15T00:00:00" // java.util.Calendar Calendar dateCalendar = Calendar.getInstance(); dateCalendar.clear(); dateCalendar.set(2016, 11, 15); jsonb.toJson(dateCalendar); // ”2016-11-15” // java.time.Instant jsonb.toJson(Instant.parse("2016-11-15T23:00:00Z")); // ”2016-11-15T23:00:00Z” // java.time.Duration jsonb.toJson(Duration.ofHours(5).plusMinutes(4)); // “PT5H4M" // java.time.Period jsonb.toJson(Period.between( LocalDate.of(1960, Month.JANUARY, 1), LocalDate.of(1970, Month.JANUARY, 1))); // "P10Y"
  • 63. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. Arrays/Collections • Collection • Map • Set • HashSet • NavigableSet • SortedSet • TreeSet • LinkedHashSet • HashMap • NavigableMap • SortedMap • TreeMap • LinkedHashMap • List • ArrayList • LinkedList • Deque • ArrayDeque • Queue • PriorityQueue 63
  • 64. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. • javax.json.JsonArray • javax.json.JsonStructure • javax.json.JsonValue • javax.json.JsonPointer • javax.json.JsonString • javax.json.JsonNumber • javax.json.JsonObject 64 JSON-P Types // JsonObject JsonBuilderFactory f = Json.createBuilderFactory(null); JsonObject jsonObject = f.createObjectBuilder() .add(“name", "Jason Bourne") .add(“city", "Prague") .build(); jsonb.toJson(jsonObject);
  • 65. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. Classes • Public and protected nested and static nested classes • Anonymous classes (serialization only) • Inheritance is supported • Default no-argument constructor is required for deserialization 65
  • 66. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. Fields • Final fields are serialized • Static fields are skipped • Transient fields are skipped • Null fields are skipped • Fields order – Lexicographical order – Parent class fields are serialized before child class fields 66
  • 67. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. public class Parent { public int parentB; public int parentA; } { "parentA": 1, "parentB": 2 } 67 Fields Order Sample
  • 68. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. public class Parent { public int parentB; public int parentA; } public class Child extends Parent { public int childB; public int childA; } { "parentA": 1, "parentB": 2 } { "parentA": 1, "parentB": 2, "childA": 3, "childB": 4 } 68 Fields Order Sample
  • 69. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. Serialization • Existing fields with public getters • Public fields with no getters • Public getter/setter pair without a corresponding field Deserialization • Existing fields with public setters • Public fields with no setters • Public getter/setter pair without a corresponding field 69 Scope and Field Access Strategy
  • 70. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. public class Foo { public final int publicFinalField; private final int privateFinalField; public static int publicStaticField; public int publicWithNoGetter; public int publicWithPrivateGetter; public Integer publicNullField = null; private int privateWithNoGetter; private int privateWithPublicGetter; public int getNoField() {}; public void setNoField(int value) {}; } { "publicFinalField": 1, "publicWithNoGetter": 1, "privateWithPublicGetter": 1, "noField": 1 } 70 Scope and Field Access Strategy
  • 71. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. • Annotations • Runtime configuration – JsonbConfig – JsonbBuilder 71 JSON-B Engine Configuration JsonbConfig config = new JsonbConfig() .withFormatting(…) .withNullValues(…) .withEncoding(…) .withStrictIJSON(…) .withPropertyNamingStrategy(…) .withPropertyOrderStrategy(…) .withPropertyVisibilityStrategy(…) .withAdapters(…) .withBinaryDataStrategy(…); Jsonb jsonb = JsonbBuilder.newBuilder() .withConfig(…) .withProvider(…) .build();
  • 72. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 72 Customizations • Property names • Property order • Ignoring properties • Null handling • Custom instantiation • Fields visibility • Date/Number Formats • Binary Encoding • Adapters • Serializers/Deserializers
  • 73. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. • Annotation – @JsonbProperty • Scope: – Field – Getter/Setter – Parameter 73 Property Names public class Customer { private int id; @JsonbProperty("name") public String firstName; } public class Customer { public int id; public String firstName; @JsonbProperty("name") public String getFirstName() { return firstName; } }
  • 74. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. Property Naming Strategy • Supported naming strategies – IDENTITY (myMixedCaseProperty) – LOWER_CASE_WITH_DASHES (my-mixed-case-property) – LOWER_CASE_WITH_UNDERSCORES (my_mixed_case_property) – UPPER_CAMEL_CASE (MyMixedCaseProperty) – UPPER_CAMEL_CASE_WITH_SPACES (My Mixed Case Property) – CASE_INSENSITIVE (mYmIxEdCaSePrOpErTy) – Or a custom implementation • JsonbConfig – withPropertyNamingStrategy(…): 74
  • 75. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. • Strategies: – LEXICOGRAPHICAL (A-Z) – ANY – REVERSE (Z-A) • Annotation – @JsonbPropertyOrder on class • JsonbConfig – withPropertyOrderStrategy(…) 75 Property Order Strategy @JsonbPropertyOrder(ANY) public class Foo { public int bar2; public int bar1; }
  • 76. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. • Annotation – @JsonbTransient 76 Ignoring Properties public class Customer { public int id; public String name; @JsonbTransient public BigDecimal salary; }
  • 77. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. • PropertyVisibilityStrategy interface • Annotation – @JsonbVisibility • JsonbConfig – withPropertyVisibilityStrategy(…) 77 Property Visibility public interface PropertyVisibilityStrategy { boolean isVisible(Field field); boolean isVisible(Method method); } public class MyStrategy implements PropertyVisibilityStrategy { /* ... */ } @JsonbVisibility(MyStrategy.class) public class Bar { private int field1; private int field2; }
  • 78. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. • Null fields are skipped by default • Annotation – @JsonbNillable • JsonbConfig – withNullValues(true) 78 Null Handling public class Customer { public int id = 1; @JsonbProperty("name", true) public String name = null; } @JsonbNillable public class Customer { public int id = 1; public String name = null; }
  • 79. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. Custom Instantiation 79 public class Customer { public int id; public String name; @JsonbCreator public static Customer create( @JsonbProperty("id") int id) { return CustomerDao.getByPrimaryKey(id); } } public class Order { public int id; public Customer customer; } { "id": 123, "customer": { "id": 562, } }
  • 80. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. • Annotations – @JsonbDateFormat – @JsonbNumberFormat • JsonbConfig – withDateFormat(…) – withLocale(…) 80 Date/Number Format public class FormatSample { public Date defaultDate; @JsonbDateFormat("dd.MM.yyyy") public Date formattedDate; public BigDecimal defaultNumber; @JsonbNumberFormat(“#0.00") public BigDecimal formattedNumber; }
  • 81. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. • Supported encodings – BYTE (default) – BASE_64 – BASE_64_URL • JsonbConfig – withBinaryDataStrategy(…) 81 Binary Data Encoding JsonbConfig config = new JsonbConfig() .withBinaryDataStrategy( BinaryDataStrategy.BASE_64); Jsonb jsonb = JsonbBuilder.create(config); String json = jsonb.toJson(obj);
  • 82. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. I-JSON • I-JSON (”Internet JSON”) is a restricted profile of JSON – https://tools.ietf.org/html/draft-ietf-json-i-json-06 • JSON-B fully supports I-JSON by default with three exceptions: – JSON Binding does not restrict the serialization of top-level JSON texts that are neither objects nor arrays. The restriction should happen at application level. – JSON Binding does not serialize binary data with base64url encoding. – JSON Binding does not enforce additional restrictions on dates/times/duration. • JsonbConfig – withStrictIJSON(true) 82
  • 83. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. • Inspired by JAXB • Annotations – @JsonbTypeAdapter annotation • JsonbConfig – withAdapters(…) 83 Adapters public interface JsonbAdapter<Original, Adapted> { Adapted adaptToJson(Original obj); Original adaptFromJson(Adapted obj); } @JsonbTypeAdapter(AnimalAdapter.class) public Animal animal; JsonbConfig config = new JsonbConfig() .withAdapters(new AnimalAdapter());
  • 84. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. • Low level control on serialization/deserialization • Annotations – @JsonbTypeSerializer – @JsonbTypeDeserializer • JsonbConfig – withSerializers(…) – withDeserializers(…) 84 Serializers/Deserializers public interface JsonbSerializer<T> { void serialize(T obj, JsonGenerator generator, SerializationContext ctx); public interface JsonbDeserializer<T> { T deserialize(JsonParser parser, DeserializationContext ctx, Type rtType); } @JsonbTypeSerializer(AnimalSerializer.class) @JsonbTypeDeserializer(AnimalDeserializer.class) public Animal animal; JsonbConfig config = new JsonbConfig() .withSerializers(new AnimalSerializer()) .withDeserializers(new AnimalDeserializer());
  • 85. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. JSON-B Demo • GitHub – https://github.com/m0mus/json_demo • Demonstrates – JSON-P • JsonParser • JsonGenerator • Working with large files • JsonPointer • JsonPatch • Using Java8 streams 85 – JSON-B • Default mapping • Adapters • Serializers/Deserializers • Mapping of generic class • Using together with JSON-P
  • 86. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. Q & A 86