SlideShare a Scribd company logo
COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 1
JSON Support in Jakarta EE:
Present and Future
Dmitry Kornilov / Andy Guibert
10 Sep 2019
2COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 2
About Us
• Jakarta JSON Processing Project Lead
• Jakarta JSON Binding Project Lead
• Eclipse EE4J PMC Member
Dmitry Kornilov
(Oracle)
• Jakarta JSON Binding Project Lead
Andy Guibert
(IBM)
COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0)
AGENDA
3
Introduction
Jakarta JSON Processing
Jakarta JSON Binding
Plans
4COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 4
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.
COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 5
Introduction
6COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 6
What is JSON?
● JavaScript Object Notation
● Open standard (RFC 7159, 8259)
● Text based
● Language independent
● Nicely readable by humans
● Supported in most of languages
● Lightweight data interchange format
{
"firstName": "John",
"lastName": "Doe",
"age": 42,
"contacts": [
{
"type": "home",
"number": "123-456-789"
}
]
}
7COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 7
What is JSON?
● Primitive types:
○ String
○ Number
○ Boolean
● Structured types:
○ Array
○ Object
● Null
{
"firstName": "John",
"lastName": "Doe",
"age": 42,
"registered": true,
"tags": null,
"contacts": [
{
"type": "home",
"number": "123-456-789"
}
]
}
8COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 8
JSON Support in Jakarta EE 8
● Jakarta JSON Processing API
○ Standard API to parse, generate, transform and query JSON
○ Object Model and Streaming API
■ similar to DOM and StAX
● Jakarta JSON Binding API
○ Binding JSON documents to Java objects
■ similar to JAXB
COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 9
Jakarta JSON Processing
10COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 10
Jakarta JSON Processing
● Web Site
○ https://eclipse-ee4j.github.io/jsonp/
● Repository
○ https://github.com/eclipse-ee4j/jsonp
● Eclipse Project
○ https://projects.eclipse.org/projects/ee4j.jsonp
● Mailing List
○ https://accounts.eclipse.org/mailing-list/jsonp-dev
11COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 11
Jakarta JSON Processing
● Streaming API
○ Event based
○ Access to one element
○ Efficient for high volume of data
○ Small memory footprint
● Object Model API
○ In-memory tree
○ Random access to elements
○ Efficient for smaller documents
○ Big memory footprint
12COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 12
Jakarta JSON Processing
● Streaming API
○ JsonParser
○ JsonGenerator
● Object Model API
○ JsonReader
○ JsonWriter
○ JsonPointer
○ JsonPatch
○ JsonMergePatch
COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 13
Streaming API
14COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 14
JsonParser
● JsonParser
○ Parses JSON in a streaming way from input sources
○ Similar to StAX’s XMLStreamReader
● 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
15COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 15
JsonParser
{
"name":
”John Doe",
"age":
42,
”contacts":
[
{
"type":
"home",
"number":
"123-456-789"
}
]
}
16COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 16
JsonParser
START_OBJECT{
"name":
”John Doe",
"age":
42,
”contacts":
[
{
"type":
"home",
"number":
"123-456-789"
}
]
}
17COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 17
JsonParser
START_OBJECT
KEY_NAME
{
"name":
”John Doe",
"age":
42,
”contacts":
[
{
"type":
"home",
"number":
"123-456-789"
}
]
}
18COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 18
JsonParser
START_OBJECT
KEY_NAME
VALUE_STRING
{
"name":
”John Doe",
"age":
42,
”contacts":
[
{
"type":
"home",
"number":
"123-456-789"
}
]
}
19COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 19
JsonParser
START_OBJECT
KEY_NAME
VALUE_STRING
KEY_NAME
{
"name":
”John Doe",
"age":
42,
”contacts":
[
{
"type":
"home",
"number":
"123-456-789"
}
]
}
20COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 20
JsonParser
START_OBJECT
KEY_NAME
VALUE_STRING
KEY_NAME
VALUE_NUMBER
{
"name":
”John Doe",
"age":
42,
”contacts":
[
{
"type":
"home",
"number":
"123-456-789"
}
]
}
21COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 21
JsonParser
START_OBJECT
KEY_NAME
VALUE_STRING
KEY_NAME
VALUE_NUMBER
KEY_NAME
{
"name":
”John Doe",
"age":
42,
”contacts":
[
{
"type":
"home",
"number":
"123-456-789"
}
]
}
22COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 22
JsonParser
START_OBJECT
KEY_NAME
VALUE_STRING
KEY_NAME
VALUE_NUMBER
KEY_NAME
START_ARRAY
{
"name":
”John Doe",
"age":
42,
”contacts":
[
{
"type":
"home",
"number":
"123-456-789"
}
]
}
23COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 23
JsonParser
START_OBJECT
KEY_NAME
VALUE_STRING
KEY_NAME
VALUE_NUMBER
KEY_NAME
START_ARRAY
START_OBJECT
{
"name":
”John Doe",
"age":
42,
”contacts":
[
{
"type":
"home",
"number":
"123-456-789"
}
]
}
24COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 24
JsonParser
START_OBJECT
KEY_NAME
VALUE_STRING
KEY_NAME
VALUE_NUMBER
KEY_NAME
START_ARRAY
START_OBJECT
KEY_NAME
{
"name":
”John Doe",
"age":
42,
”contacts":
[
{
"type":
"home",
"number":
"123-456-789"
}
]
}
25COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 25
JsonParser
START_OBJECT
KEY_NAME
VALUE_STRING
KEY_NAME
VALUE_NUMBER
KEY_NAME
START_ARRAY
START_OBJECT
KEY_NAME
VALUE_STRING
{
"name":
”John Doe",
"age":
42,
”contacts":
[
{
"type":
"home",
"number":
"123-456-789"
}
]
}
26COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 26
JsonParser
START_OBJECT
KEY_NAME
VALUE_STRING
KEY_NAME
VALUE_NUMBER
KEY_NAME
START_ARRAY
START_OBJECT
KEY_NAME
VALUE_STRING
KEY_NAME
{
"name":
”John Doe",
"age":
42,
”contacts":
[
{
"type":
"home",
"number":
"123-456-789"
}
]
}
27COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 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":
”John Doe",
"age":
42,
”contacts":
[
{
"type":
"home",
"number":
"123-456-789"
}
]
}
28COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 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":
”John Doe",
"age":
42,
”contacts":
[
{
"type":
"home",
"number":
"123-456-789"
}
]
}
29COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 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":
”John Doe",
"age":
42,
”contacts":
[
{
"type":
"home",
"number":
"123-456-789"
}
]
}
30COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 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":
”John Doe",
"age":
42,
”contacts":
[
{
"type":
"home",
"number":
"123-456-789"
}
]
}
31COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 31
JsonParser
JsonParser parser = Json.createParser(...);
Event e = parser.next(); // START_OBJECT
parser.next(); // KEY_NAME
parser.getString(); // name
parser.next(); // VALUE_STRING
parser.getString(); // John Doe
parser.next(); // KEY_NAME
parser.getString(); // age
parser.next(); // VALUE_NUMBER
parser.getInt(); // 42
{
"name":
”John Doe",
"age":
42,
”contacts":
[
{
"type":
"home",
"number":
"123-456-789"
}
]
}
32COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 32
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
● Uses builder pattern
33COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 33
JsonGenerator
JsonGenerator g = Json.createGenerator(…);
g.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 (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 34
Object Model API
35COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 35
Object Model API
● Builder to build JsonObject and JsonArray from scratch
● Type-safe (cannot mix array and object building methods)
● Can also use existing JsonObject and JsonArray in a builder
36COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 36
Object Model API
JsonArray value = Json.createArrayBuilder()
.add(Json.createObjectBuilder()
.add("type", "home")
.add("number", "123-456-789")
)
.add(Json.createObjectBuilder()
.add("type", "fax")
.add("number", "123-456-790")
)
.build();
[
{
"type": "home”,
"number": "123-456-789"
},
{
"type": "fax”,
"number": "123-456-790"
}
]
37COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 37
JsonPointer
● IETF RFC 6901
● String syntax for identifying a specific value
○ /phone/mobile
○ /parents/0
● Special characters
○ "/" —> "~1"
○ "~" —> "~0"
38COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 38
JsonPointer Sample
JsonArray customers = . . .;
JsonPointer pointer =
Json.createPointer("/1/lastName");
// Set new value
pointer.replace(customers,
Json.createValue(”Doe"));
// Get the value
JsonValue lastName =
pointer.getValue(customers); // Doe
[
{
"firstName": "John",
"lastName": "Doe",
"age": 42
},
{
"firstName": "Jane",
"lastName": " ",
"age": 35
}
]
39COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 39
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)
[
{ "op": "replace",
"path": "/1/lastName",
"value": ”Doe" },
{ "op": "remove",
"path": "/2" }
]
40COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 40
JsonPatch Sample
[
{
"firstName": "John",
"lastName": "Doe",
"age": 42
},
{
"firstName": "Jane",
"lastName": "Doe",
"age": 35
},
{
"firstName": "John",
"lastName": "Doe",
"age": 42
}
]
[
{ "op": "replace",
"path": "/1/lastName",
"value": ”Doe" },
{ "op": "remove",
"path": "/2" }
]
41COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 41
JsonPatch Sample
[
{
"firstName": "John",
"lastName": "Doe",
"age": 42
},
{
"firstName": "Jane",
"lastName": "Doe",
"age": 35
},
{
"firstName": "John",
"lastName": "Doe",
"age": 42
}
]
[
{ "op": "replace",
"path": "/1/lastName",
"value": ”Doe" },
{ "op": "remove",
"path": "/2" }
]
42COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 42
JsonPatch Sample
[
{ "op": "replace",
"path": "/1/lastName",
"value": "Doe" },
{ "op": "remove",
"path": "/2" }
]
// Create JsonPatch
JsonPatch patch = Json.createPatchBuilder()
.replace("/1/lastName", "Doe")
.remove("/2")
.build();
// Apply patch
patch.apply(list);
// Read patch JSON
JsonArray patchData =
Json.createReader(…).readArray();
// Create patch
JsonPatch patch = Json.createPatch(patchData);
// Apply patch
patch.apply(list);
or
43COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 43
JsonMergePatch
● IETF RFC 7396
● HTTP PATCH
"application/merge-patch+json"
● Patch is a JSON document itself
● Syntax closely mimics the document
○ Git like merge experience
// Read patch JSON
JsonObject patchData =
Json.createReader(…).readArray();
// Create patch
JsonMergePatch mergePatch =
Json.createMergePatch(patchData);
// Apply patch
mergePatch.apply(applyTo);
44COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 44
JsonMergePatch
{
"firstName": "John",
"lastName": "Doe",
"age": 42
}
{
"firstName": "John",
"lastName": " ",
"address": " "
}
{
"lastName": ”Doe",
"age": 42,
"address": null
}
Source
Patch
Result
COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 45
Jakarta JSON Binding
46COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 46
Jakarta JSON Binding
● API to serialize/deserialize Java objects to/from JSON documents
○ Similar to JAX-B, except with JSON instead of XML
○ Standardizes features of the current technologies (Jackson, Genson, Gson)
● Easily convert between Java classes and JSON data with convenient default settings
● Customization APIs
○ Annotations (@JsonbProperty, @JsonbNillable)
○ Runtime configuration builder
● Natural follow on to JSON-P
○ Closes the JSON support gap
○ Allows to use different JSONP providers
47COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 47
Jakarta JSON Binding
● Web Site
○ https://eclipse-ee4j.github.io/jsonb-api/
● Repository
○ https://github.com/eclipse-ee4j/jsonb-api
● Eclipse Project
○ https://projects.eclipse.org/projects/ee4j.jsonb
● Mailing List
○ https://accounts.eclipse.org/mailing-list/jsonb-dev
COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 48
Default Mapping
49COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 49
Default Mapping
● No configuration, no annotations
● The scope:
○ Basic Types
○ Specific JDK Types
○ Dates
○ Classes
○ Collections/Arrays
○ Enumerations
○ JSON-P model classes
import javax.json.bind.Jsonb;
import javax.json.bind.JsonbBuilder;
// Create with default config
// Cache it!
Jsonb jsonb = JsonbBuilder.create();
50COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 50
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);
}
51COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 51
JSON-B Sample
Person person1 = new Person();
person1.setFirstName("John");
person1.setLastName(”Doe");
person1.setAge(42);
Person person2 = new Person();
person2.setFirstName("Jane");
person2.setLastName(”Doe");
person2.setAge(35);
List<Person> persons = new ArrayList<>();
persons.add(person1);
persons.add(person2);
Jsonb jsonb = JsonbBuilder.create();
jsonb.toJson(persons);
[
{
"firstName": "John",
"lastName": "Doe",
"age": 42
},
{
"firstName": "Jane",
"lastName": "Doe",
"age": 35
}
]
52COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 52
Basic and Specific Types
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
53COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0)
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
53
Date / Time
54COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 54
Data / Time Samples
// java.util.Date
SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy");
Date parsedDate = sdf.parse("10.09.2019");
jsonb.toJson(parsedDate)); // ”2019-09-10T00:00:00"
// java.util.Calendar
Calendar dateCalendar = Calendar.getInstance();
dateCalendar.clear();
dateCalendar.set(2019, 9, 10);
jsonb.toJson(dateCalendar); // ”2019-09-10”
// java.time.Instant
jsonb.toJson(Instant.parse("2019-09-10T23:00:00Z")); // ”2019-09-10T23: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"
55COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 55
Arrays / Collections
● Collection
● Map
● Set
● HashSet
● NavigableSet
● SortedSet
● TreeSet
● LinkedHashSet
● TreeHashSet
● HashMap
● NavigableMap
● SortedMap
● TreeMap
● LinkedHashMap
● TreeHashMap
● List
● ArrayList
● LinkedList
● Deque
● ArrayDeque
● Queue
● PriorityQueue
● EnumSet (JSONB.next)
● EnumMap (JSONB.next)
56COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 56
JSON-P Types
● JsonValue
● JsonPointer
● JsonString
● JsonNumber
● JsonObject
● JsonArray
● JsonStructure
// JsonObject
JsonBuilderFactory f =
Json.createBuilderFactory(null);
JsonObject jsonObject =
f.createObjectBuilder()
.add(“firstName", "John")
.add(“lastName", "Doe")
.build();
String json = jsonb.toJson(jsonObject);
57COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 57
Classes
● Public and protected nested and static nested classes
● Anonymous classes (serialization only)
● Inheritance is supported
● Default no-argument constructor is required for default deserialization
58COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 58
Fields
● Final fields are serialized
● Static fields are skipped
● Transient fields are skipped
● Null fields are skipped
● Fields order
○ Lexicographical (A-Z) order
○ Parent class fields are serialized before child class fields
59COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 59
Field Order Sample
public class Parent {
public int parentB;
public int parentA;
}
{
"parentA": 1,
"parentB": 2
}
60COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 60
Field Order Sample
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
}
61COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 61
Scope and Field Access Strategy
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
62COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 62
Scope and Field Access Strategy
{
"publicFinalField": 1,
"publicWithNoGetter": 1,
"privateWithPublicGetter": 1,
"noField": 1
}
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) {};
}
COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 63
Customized Mapping
64COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 64
JSON-B Engine Configuration
● Annotations
● Runtime configuration
○ JsonbConfig
○ JsonbBuilder
JsonbConfig config = new JsonbConfig()
.withFormatting(…)
.withNullValues(…)
.withEncoding(…)
.withStrictIJSON(…)
.withPropertyNamingStrategy(…)
.withPropertyOrderStrategy(…)
.withPropertyVisibilityStrategy(…)
.withAdapters(…)
.withBinaryDataStrategy(…);
Jsonb jsonb = JsonbBuilder.newBuilder()
.withConfig(…)
.withProvider(…)
.build();
65COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 65
Customizations
● Property names
● Property order
● Ignoring properties
● Null handling
● Custom instantiation
● Property visibility
● Date/Number Formats
● Binary Encoding
● Adapters
● Serializers/Deserializers
66COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 66
Property Names
● Annotation
○ @JsonbProperty
● Scope:
○ Field
○ Getter/Setter
○ Parameter
public class Customer {
public int id;
@JsonbProperty("name")
public String firstName;
}
public class Customer {
public int id;
private String firstName;
@JsonbProperty("name")
public String getFirstName() {
return firstName;
}
}
67COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 67
Property Naming Strategy
● Globally changes the way of naming properties
● Supported a set of predefined strategies (see next slide)
○ JsonbConfig. withPropertyNamingStrategy(String strategyName)
● Ability to write your own strategy
○ Implement PropertyNamingStrategy interface
○ JsonbConfig. withPropertyNamingStrategy(PropertyNamingStrategy name);
68COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 68
Predefined Property Naming Strategies
Strategy Name Sample
IDENTITY (default) myProperty → myProperty
LOWER_CASE_WITH_DASHES myProperty → my-property
LOWER_CASE_WITH_UNDERSCORES myProperty → my_property
UPPER_CAMEL_CASE myProperty → MyProperty
UPPER_CAMEL_CASE_WITH_SPACES myProperty → "My Property"
CASE_INSENSITIVE the same as IDENTITY but ignores case on
deserialization
Custom Strategy Custom case conversion login
69COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 69
Property Order Strategy
● Strategies:
○ LEXICOGRAPHICAL (A-Z)
○ ANY
○ REVERSE (Z-A)
● Annotation
○ @JsonbPropertyOrder on class
● JsonbConfig
○ withPropertyOrderStrategy(…)
@JsonbPropertyOrder(ANY)
public class Foo {
public int bar2;
public int bar1;
}
70COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 70
Ignoring Properties
● Annotation
○ @JsonbTransient
public class Foo {
public int bar2;
@JsonbTransient
public int bar1;
}
71COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 71
Property Visibility
● PropertyVisibilityStrategy interface
● Annotation
○ @JsonbVisibility
● JsonbConfig
○ withPropertyVisibilityStrategy(…)
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;
}
72COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 72
Null Handling
● Null fields are skipped by default
● Annotation
○ @JsonbNillable
● JsonbConfig
○ withNullValues(true)
public class Customer {
public int id = 1;
@JsonbProperty(nillable=true)
public String name = null;
}
@JsonbNillable
public class Customer {
public int id = 1;
public String name = null;
}
73COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 73
Custom Instantiation
public class Order {
public int id;
public Customer customer;
}
public class Customer {
...
@JsonbCreator
public static Customer getFromDb(
@JsonbProperty int id) {
return CustomerDao.getByPrimaryKey(id);
}
}
{
"id": 123,
"customer": {
"id": 562,
}
}
● Use @JsonbCreator when a class does
not have a default (no-args) constructor
● At most one @JsonbCreator can be used
per class
● Can be used on a constructor or static
creator method
74COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 74
Date / Number Format
● Annotations
○ @JsonbDateFormat
○ @JsonbNumberFormat
● JsonbConfig
○ withDateFormat(…)
○ withLocale(…)
public class FormatSample {
public Date defaultDate;
@JsonbDateFormat("dd.MM.yyyy")
public Date formattedDate;
public BigDecimal defaultNumber;
@JsonbNumberFormat(“#0.00")
public BigDecimal formattedNumber;
}
75COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 75
Binary Data Encoding
● Supported encodings
○ BYTE (default)
○ BASE_64
○ BASE_64_URL
● JsonbConfig
○ withBinaryDataStrategy(…)
JsonbConfig config = new JsonbConfig()
.withBinaryDataStrategy(
BinaryDataStrategy.BASE_64);
Jsonb jsonb = JsonbBuilder.create(config);
String json = jsonb.toJson(obj);
76COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 76
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)
77COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 77
Adapters
● Inspired by JAXB
● Annotations
○ @JsonbTypeAdapter annotation
● JsonbConfig
○ withAdapters(…)
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());
78COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 78
Adapters
● Inspired by JAXB
● Annotations
○ @JsonbTypeAdapter annotation
● JsonbConfig
○ withAdapters(…)
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());
79COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 79
Serializers / Deserializers
● Low level control on
serialization/deserialization
● Annotations
○ @JsonbTypeSerializer
○ @JsonbTypeDeserializer
● JsonbConfig
○ withSerializers(…)
○ withDeserializers(…)
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 (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 80
Plans
81COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 81
Future JSON-B Plans
● Larger features
○ Customize 3rd party classes (jsonb-api #88)
○ Polymorphic [De]serialization (jsonb-api #147)
○ Map directly to/from JsonGenerator and JsonParser (jsonb-api #122)
● Smaller features
○ Using @JsonbCreator with absent/optional fields (jsonb-api #121)
○ Configurable interface  impl mappings (jsonb-api #65)
○ Automatically register Adapters/[De]Serializers (jsonb-api #35)
○ Opt out of the “must ignore” policy (jsonb-api #56)
○ Customize date formats of different types (jsonb-api #87)
82COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 82
Customizing 3rd party classes
● Be able to customize classes you cannot modify
● Similar use-case as Jackson mix-ins
// Cannot modify this class
// Comes from 3rd party dependency
public class Dog {
// @JsonbProperty(“dogName”)
public String name;
public int age;
// @JsonbTransient
public Owner owner;
}
ClassCustomization c = ClassCustomization.for(Dog.class)
.property(”name”, ”dogName”)
.transient(”owner”)
// The ”age” property not mentioned, so it is left as-is
.build();
JsonbConfig config = new JsonbConfig()
.withClassCustomization(c);
83COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 83
Polymorphic [de]serialization
● Allows for properties in the JSON data to be
used to determine the Java deserialization class
● Highly requested feature, but security sensitive
PolymorphicConfig poly = PolymorphicConfig.builder()
.withClasses(Dog.class, Cat.class)
.withTypeAttribute(”jsonb_class”); // optional
JsonbConfig config = new JsonbConfig()
.withPolymorphicConfig(poly);
{
”jsonb_class": ”com.foo.Dog”
”name": ”Spot”
”bites": false
}
{
”jsonb_class": ”com.foo.Cat”
”name": ”Princess”
”meows": true
}
84COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 84
Custom constructors with absent parameters
● JSON-B classes can have at most 1
@JsonbCreator annotated constructor
● Object might need to be constructed without
some properties present
● Particularly useful for immutable data objects
public class Person {
public final String firstName;
public final String middleName;
public final String lastName;
@JsonbCreator
public Person(
@JsonbCreator(”firstName”) String first,
@JsonbCreator(”middleName”) String mid,
@JsonbCreator(”lastName”) String last) {
this.firstName = first;
this.middleName = mid;
this.lastName = last;
}
}{
"firstName": "Jane",
"lastName": "Doe"
}
85COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 85
Automatically register Adapters and [De]Serializers
● Add new annotations to automatically
register JsonbAdapter, JsonbSerializer, and
JsonbDeserializer when CDI is present
● No need to manually register objects with
JsonbConfig
@RegisterJsonbAdapter
public class PersonAdapter implements
JsonbAdapter<Person, Map<String,Object>> {
// ...
}
JsonbConfig config = new JsonbConfig()
.withAdapters(new PersonAdapter());
86COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 86
Opt-out of the ”Must-Ignore” policy
● By default JSON-B will ignore unrecognized
properties on deserialization
● Provide way to opt-out so an error is raised
if unrecognized properties are encountered
{
”first": "Jane",
”last": "Doe"
}
JsonbConfig config = new JsonbConfig()
.withAllowUnrecognized(false);
// ...
// Fails with JsonbException because
// ‘first’ and ‘last’ properties not recognized
Person p = jsonb.fromJson(json, Person.class)
public class Person {
public String firstName;
public String middleName;
public String lastName;
}
87COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 87
Future JSON-B Plans
● See Github project board for complete overview and up-to-date information
https://github.com/eclipse-ee4j/jsonb-api/projects/1
COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 88
Thank you!

More Related Content

Similar to JSON Support in Jakarta EE: Present and Future

Jakarta EE 8: Overview of Features
Jakarta EE 8: Overview of FeaturesJakarta EE 8: Overview of Features
Jakarta EE 8: Overview of Features
Josh Juneau
 
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
 
2019.02 Eclipse Foundation and Eclipse IoT presentation at Eclipse IoT Day Gr...
2019.02 Eclipse Foundation and Eclipse IoT presentation at Eclipse IoT Day Gr...2019.02 Eclipse Foundation and Eclipse IoT presentation at Eclipse IoT Day Gr...
2019.02 Eclipse Foundation and Eclipse IoT presentation at Eclipse IoT Day Gr...
Gaël Blondelle
 
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
 
JSON Support in DB2 for z/OS
JSON Support in DB2 for z/OSJSON Support in DB2 for z/OS
JSON Support in DB2 for z/OS
Jane Man
 
Akademy es 2021 the Eclipse Foundation introduction and Oniro project
Akademy es 2021 the Eclipse Foundation introduction and Oniro projectAkademy es 2021 the Eclipse Foundation introduction and Oniro project
Akademy es 2021 the Eclipse Foundation introduction and Oniro project
Agustin Benito Bethencourt
 
When SDMX meets AI-Leveraging Open Source LLMs To Make Official Statistics Mo...
When SDMX meets AI-Leveraging Open Source LLMs To Make Official Statistics Mo...When SDMX meets AI-Leveraging Open Source LLMs To Make Official Statistics Mo...
When SDMX meets AI-Leveraging Open Source LLMs To Make Official Statistics Mo...
Sease
 
Introduction to Json ld
Introduction to Json ldIntroduction to Json ld
Introduction to Json ld
Bo Kai Hsu
 
Generating Unified APIs with Protocol Buffers and gRPC
Generating Unified APIs with Protocol Buffers and gRPCGenerating Unified APIs with Protocol Buffers and gRPC
Generating Unified APIs with Protocol Buffers and gRPC
C4Media
 
JakartaOne Livestream CN4J: Driving Jakarta EE Success
JakartaOne Livestream CN4J: Driving Jakarta EE SuccessJakartaOne Livestream CN4J: Driving Jakarta EE Success
JakartaOne Livestream CN4J: Driving Jakarta EE Success
Jakarta_EE
 
Iot developer-survey-2019
Iot developer-survey-2019Iot developer-survey-2019
Iot developer-survey-2019
MichaelRodriguesdosS1
 
IoT Developer Survey 2019 Report
IoT Developer Survey 2019 ReportIoT Developer Survey 2019 Report
IoT Developer Survey 2019 Report
Eclipse IoT
 
Java EE 7 overview
Java EE 7 overviewJava EE 7 overview
Java EE 7 overview
Masoud Kalali
 
Jakarta EE 9 Milestone Release Party - Overview
Jakarta EE 9 Milestone Release Party - OverviewJakarta EE 9 Milestone Release Party - Overview
Jakarta EE 9 Milestone Release Party - Overview
Jakarta_EE
 
What's new in c# 10
What's new in c# 10What's new in c# 10
What's new in c# 10
Moaid Hathot
 
What's new in c# 10
What's new in c# 10What's new in c# 10
What's new in c# 10
Moaid Hathot
 
Eclipse Foundation Overview (April 2019)
Eclipse Foundation Overview (April 2019)Eclipse Foundation Overview (April 2019)
Eclipse Foundation Overview (April 2019)
Thabang Mashologu
 
Application Development & Database Choices: Postgres Support for non Relation...
Application Development & Database Choices: Postgres Support for non Relation...Application Development & Database Choices: Postgres Support for non Relation...
Application Development & Database Choices: Postgres Support for non Relation...
EDB
 
Open Source is eating the world...
Open Source is eating the world...Open Source is eating the world...
Open Source is eating the world...
Philippe Krief
 
Visualizing Open Data with Neo4J
Visualizing Open Data with Neo4JVisualizing Open Data with Neo4J
Visualizing Open Data with Neo4J
Scott Sosna
 

Similar to JSON Support in Jakarta EE: Present and Future (20)

Jakarta EE 8: Overview of Features
Jakarta EE 8: Overview of FeaturesJakarta EE 8: Overview of Features
Jakarta EE 8: Overview of Features
 
JSON Support in Java EE 8
JSON Support in Java EE 8JSON Support in Java EE 8
JSON Support in Java EE 8
 
2019.02 Eclipse Foundation and Eclipse IoT presentation at Eclipse IoT Day Gr...
2019.02 Eclipse Foundation and Eclipse IoT presentation at Eclipse IoT Day Gr...2019.02 Eclipse Foundation and Eclipse IoT presentation at Eclipse IoT Day Gr...
2019.02 Eclipse Foundation and Eclipse IoT presentation at Eclipse IoT Day Gr...
 
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
 
JSON Support in DB2 for z/OS
JSON Support in DB2 for z/OSJSON Support in DB2 for z/OS
JSON Support in DB2 for z/OS
 
Akademy es 2021 the Eclipse Foundation introduction and Oniro project
Akademy es 2021 the Eclipse Foundation introduction and Oniro projectAkademy es 2021 the Eclipse Foundation introduction and Oniro project
Akademy es 2021 the Eclipse Foundation introduction and Oniro project
 
When SDMX meets AI-Leveraging Open Source LLMs To Make Official Statistics Mo...
When SDMX meets AI-Leveraging Open Source LLMs To Make Official Statistics Mo...When SDMX meets AI-Leveraging Open Source LLMs To Make Official Statistics Mo...
When SDMX meets AI-Leveraging Open Source LLMs To Make Official Statistics Mo...
 
Introduction to Json ld
Introduction to Json ldIntroduction to Json ld
Introduction to Json ld
 
Generating Unified APIs with Protocol Buffers and gRPC
Generating Unified APIs with Protocol Buffers and gRPCGenerating Unified APIs with Protocol Buffers and gRPC
Generating Unified APIs with Protocol Buffers and gRPC
 
JakartaOne Livestream CN4J: Driving Jakarta EE Success
JakartaOne Livestream CN4J: Driving Jakarta EE SuccessJakartaOne Livestream CN4J: Driving Jakarta EE Success
JakartaOne Livestream CN4J: Driving Jakarta EE Success
 
Iot developer-survey-2019
Iot developer-survey-2019Iot developer-survey-2019
Iot developer-survey-2019
 
IoT Developer Survey 2019 Report
IoT Developer Survey 2019 ReportIoT Developer Survey 2019 Report
IoT Developer Survey 2019 Report
 
Java EE 7 overview
Java EE 7 overviewJava EE 7 overview
Java EE 7 overview
 
Jakarta EE 9 Milestone Release Party - Overview
Jakarta EE 9 Milestone Release Party - OverviewJakarta EE 9 Milestone Release Party - Overview
Jakarta EE 9 Milestone Release Party - Overview
 
What's new in c# 10
What's new in c# 10What's new in c# 10
What's new in c# 10
 
What's new in c# 10
What's new in c# 10What's new in c# 10
What's new in c# 10
 
Eclipse Foundation Overview (April 2019)
Eclipse Foundation Overview (April 2019)Eclipse Foundation Overview (April 2019)
Eclipse Foundation Overview (April 2019)
 
Application Development & Database Choices: Postgres Support for non Relation...
Application Development & Database Choices: Postgres Support for non Relation...Application Development & Database Choices: Postgres Support for non Relation...
Application Development & Database Choices: Postgres Support for non Relation...
 
Open Source is eating the world...
Open Source is eating the world...Open Source is eating the world...
Open Source is eating the world...
 
Visualizing Open Data with Neo4J
Visualizing Open Data with Neo4JVisualizing Open Data with Neo4J
Visualizing Open Data with Neo4J
 

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
 
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
 
Introduction to Yasson
Introduction to YassonIntroduction to Yasson
Introduction to Yasson
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 (16)

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
 
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
 
Introduction to Yasson
Introduction to YassonIntroduction to Yasson
Introduction to Yasson
 
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

Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
saastr
 
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their MainframeDigital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Precisely
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
ssuserfac0301
 
A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024
Intelisync
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
Pixlogix Infotech
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
Miro Wengner
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
Brandon Minnick, MBA
 
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-EfficiencyFreshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
ScyllaDB
 
SAP S/4 HANA sourcing and procurement to Public cloud
SAP S/4 HANA sourcing and procurement to Public cloudSAP S/4 HANA sourcing and procurement to Public cloud
SAP S/4 HANA sourcing and procurement to Public cloud
maazsz111
 
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
Edge AI and Vision Alliance
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
saastr
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
Hiroshi SHIBATA
 
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
Alex Pruden
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
DanBrown980551
 
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying AheadDigital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Wask
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Alpen-Adria-Universität
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 

Recently uploaded (20)

Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
 
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their MainframeDigital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
Digital Banking in the Cloud: How Citizens Bank Unlocked Their Mainframe
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
 
A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024A Comprehensive Guide to DeFi Development Services in 2024
A Comprehensive Guide to DeFi Development Services in 2024
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
 
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-EfficiencyFreshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
 
SAP S/4 HANA sourcing and procurement to Public cloud
SAP S/4 HANA sourcing and procurement to Public cloudSAP S/4 HANA sourcing and procurement to Public cloud
SAP S/4 HANA sourcing and procurement to Public cloud
 
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
 
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
zkStudyClub - LatticeFold: A Lattice-based Folding Scheme and its Application...
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
 
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying AheadDigital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying Ahead
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 

JSON Support in Jakarta EE: Present and Future

  • 1. COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 1 JSON Support in Jakarta EE: Present and Future Dmitry Kornilov / Andy Guibert 10 Sep 2019
  • 2. 2COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 2 About Us • Jakarta JSON Processing Project Lead • Jakarta JSON Binding Project Lead • Eclipse EE4J PMC Member Dmitry Kornilov (Oracle) • Jakarta JSON Binding Project Lead Andy Guibert (IBM)
  • 3. COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) AGENDA 3 Introduction Jakarta JSON Processing Jakarta JSON Binding Plans
  • 4. 4COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 4 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.
  • 5. COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 5 Introduction
  • 6. 6COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 6 What is JSON? ● JavaScript Object Notation ● Open standard (RFC 7159, 8259) ● Text based ● Language independent ● Nicely readable by humans ● Supported in most of languages ● Lightweight data interchange format { "firstName": "John", "lastName": "Doe", "age": 42, "contacts": [ { "type": "home", "number": "123-456-789" } ] }
  • 7. 7COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 7 What is JSON? ● Primitive types: ○ String ○ Number ○ Boolean ● Structured types: ○ Array ○ Object ● Null { "firstName": "John", "lastName": "Doe", "age": 42, "registered": true, "tags": null, "contacts": [ { "type": "home", "number": "123-456-789" } ] }
  • 8. 8COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 8 JSON Support in Jakarta EE 8 ● Jakarta JSON Processing API ○ Standard API to parse, generate, transform and query JSON ○ Object Model and Streaming API ■ similar to DOM and StAX ● Jakarta JSON Binding API ○ Binding JSON documents to Java objects ■ similar to JAXB
  • 9. COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 9 Jakarta JSON Processing
  • 10. 10COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 10 Jakarta JSON Processing ● Web Site ○ https://eclipse-ee4j.github.io/jsonp/ ● Repository ○ https://github.com/eclipse-ee4j/jsonp ● Eclipse Project ○ https://projects.eclipse.org/projects/ee4j.jsonp ● Mailing List ○ https://accounts.eclipse.org/mailing-list/jsonp-dev
  • 11. 11COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 11 Jakarta JSON Processing ● Streaming API ○ Event based ○ Access to one element ○ Efficient for high volume of data ○ Small memory footprint ● Object Model API ○ In-memory tree ○ Random access to elements ○ Efficient for smaller documents ○ Big memory footprint
  • 12. 12COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 12 Jakarta JSON Processing ● Streaming API ○ JsonParser ○ JsonGenerator ● Object Model API ○ JsonReader ○ JsonWriter ○ JsonPointer ○ JsonPatch ○ JsonMergePatch
  • 13. COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 13 Streaming API
  • 14. 14COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 14 JsonParser ● JsonParser ○ Parses JSON in a streaming way from input sources ○ Similar to StAX’s XMLStreamReader ● 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
  • 15. 15COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 15 JsonParser { "name": ”John Doe", "age": 42, ”contacts": [ { "type": "home", "number": "123-456-789" } ] }
  • 16. 16COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 16 JsonParser START_OBJECT{ "name": ”John Doe", "age": 42, ”contacts": [ { "type": "home", "number": "123-456-789" } ] }
  • 17. 17COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 17 JsonParser START_OBJECT KEY_NAME { "name": ”John Doe", "age": 42, ”contacts": [ { "type": "home", "number": "123-456-789" } ] }
  • 18. 18COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 18 JsonParser START_OBJECT KEY_NAME VALUE_STRING { "name": ”John Doe", "age": 42, ”contacts": [ { "type": "home", "number": "123-456-789" } ] }
  • 19. 19COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 19 JsonParser START_OBJECT KEY_NAME VALUE_STRING KEY_NAME { "name": ”John Doe", "age": 42, ”contacts": [ { "type": "home", "number": "123-456-789" } ] }
  • 20. 20COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 20 JsonParser START_OBJECT KEY_NAME VALUE_STRING KEY_NAME VALUE_NUMBER { "name": ”John Doe", "age": 42, ”contacts": [ { "type": "home", "number": "123-456-789" } ] }
  • 21. 21COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 21 JsonParser START_OBJECT KEY_NAME VALUE_STRING KEY_NAME VALUE_NUMBER KEY_NAME { "name": ”John Doe", "age": 42, ”contacts": [ { "type": "home", "number": "123-456-789" } ] }
  • 22. 22COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 22 JsonParser START_OBJECT KEY_NAME VALUE_STRING KEY_NAME VALUE_NUMBER KEY_NAME START_ARRAY { "name": ”John Doe", "age": 42, ”contacts": [ { "type": "home", "number": "123-456-789" } ] }
  • 23. 23COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 23 JsonParser START_OBJECT KEY_NAME VALUE_STRING KEY_NAME VALUE_NUMBER KEY_NAME START_ARRAY START_OBJECT { "name": ”John Doe", "age": 42, ”contacts": [ { "type": "home", "number": "123-456-789" } ] }
  • 24. 24COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 24 JsonParser START_OBJECT KEY_NAME VALUE_STRING KEY_NAME VALUE_NUMBER KEY_NAME START_ARRAY START_OBJECT KEY_NAME { "name": ”John Doe", "age": 42, ”contacts": [ { "type": "home", "number": "123-456-789" } ] }
  • 25. 25COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 25 JsonParser START_OBJECT KEY_NAME VALUE_STRING KEY_NAME VALUE_NUMBER KEY_NAME START_ARRAY START_OBJECT KEY_NAME VALUE_STRING { "name": ”John Doe", "age": 42, ”contacts": [ { "type": "home", "number": "123-456-789" } ] }
  • 26. 26COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 26 JsonParser START_OBJECT KEY_NAME VALUE_STRING KEY_NAME VALUE_NUMBER KEY_NAME START_ARRAY START_OBJECT KEY_NAME VALUE_STRING KEY_NAME { "name": ”John Doe", "age": 42, ”contacts": [ { "type": "home", "number": "123-456-789" } ] }
  • 27. 27COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 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": ”John Doe", "age": 42, ”contacts": [ { "type": "home", "number": "123-456-789" } ] }
  • 28. 28COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 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": ”John Doe", "age": 42, ”contacts": [ { "type": "home", "number": "123-456-789" } ] }
  • 29. 29COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 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": ”John Doe", "age": 42, ”contacts": [ { "type": "home", "number": "123-456-789" } ] }
  • 30. 30COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 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": ”John Doe", "age": 42, ”contacts": [ { "type": "home", "number": "123-456-789" } ] }
  • 31. 31COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 31 JsonParser JsonParser parser = Json.createParser(...); Event e = parser.next(); // START_OBJECT parser.next(); // KEY_NAME parser.getString(); // name parser.next(); // VALUE_STRING parser.getString(); // John Doe parser.next(); // KEY_NAME parser.getString(); // age parser.next(); // VALUE_NUMBER parser.getInt(); // 42 { "name": ”John Doe", "age": 42, ”contacts": [ { "type": "home", "number": "123-456-789" } ] }
  • 32. 32COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 32 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 ● Uses builder pattern
  • 33. 33COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 33 JsonGenerator JsonGenerator g = Json.createGenerator(…); g.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" } ]
  • 34. COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 34 Object Model API
  • 35. 35COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 35 Object Model API ● Builder to build JsonObject and JsonArray from scratch ● Type-safe (cannot mix array and object building methods) ● Can also use existing JsonObject and JsonArray in a builder
  • 36. 36COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 36 Object Model API JsonArray value = Json.createArrayBuilder() .add(Json.createObjectBuilder() .add("type", "home") .add("number", "123-456-789") ) .add(Json.createObjectBuilder() .add("type", "fax") .add("number", "123-456-790") ) .build(); [ { "type": "home”, "number": "123-456-789" }, { "type": "fax”, "number": "123-456-790" } ]
  • 37. 37COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 37 JsonPointer ● IETF RFC 6901 ● String syntax for identifying a specific value ○ /phone/mobile ○ /parents/0 ● Special characters ○ "/" —> "~1" ○ "~" —> "~0"
  • 38. 38COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 38 JsonPointer Sample JsonArray customers = . . .; JsonPointer pointer = Json.createPointer("/1/lastName"); // Set new value pointer.replace(customers, Json.createValue(”Doe")); // Get the value JsonValue lastName = pointer.getValue(customers); // Doe [ { "firstName": "John", "lastName": "Doe", "age": 42 }, { "firstName": "Jane", "lastName": " ", "age": 35 } ]
  • 39. 39COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 39 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) [ { "op": "replace", "path": "/1/lastName", "value": ”Doe" }, { "op": "remove", "path": "/2" } ]
  • 40. 40COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 40 JsonPatch Sample [ { "firstName": "John", "lastName": "Doe", "age": 42 }, { "firstName": "Jane", "lastName": "Doe", "age": 35 }, { "firstName": "John", "lastName": "Doe", "age": 42 } ] [ { "op": "replace", "path": "/1/lastName", "value": ”Doe" }, { "op": "remove", "path": "/2" } ]
  • 41. 41COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 41 JsonPatch Sample [ { "firstName": "John", "lastName": "Doe", "age": 42 }, { "firstName": "Jane", "lastName": "Doe", "age": 35 }, { "firstName": "John", "lastName": "Doe", "age": 42 } ] [ { "op": "replace", "path": "/1/lastName", "value": ”Doe" }, { "op": "remove", "path": "/2" } ]
  • 42. 42COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 42 JsonPatch Sample [ { "op": "replace", "path": "/1/lastName", "value": "Doe" }, { "op": "remove", "path": "/2" } ] // Create JsonPatch JsonPatch patch = Json.createPatchBuilder() .replace("/1/lastName", "Doe") .remove("/2") .build(); // Apply patch patch.apply(list); // Read patch JSON JsonArray patchData = Json.createReader(…).readArray(); // Create patch JsonPatch patch = Json.createPatch(patchData); // Apply patch patch.apply(list); or
  • 43. 43COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 43 JsonMergePatch ● IETF RFC 7396 ● HTTP PATCH "application/merge-patch+json" ● Patch is a JSON document itself ● Syntax closely mimics the document ○ Git like merge experience // Read patch JSON JsonObject patchData = Json.createReader(…).readArray(); // Create patch JsonMergePatch mergePatch = Json.createMergePatch(patchData); // Apply patch mergePatch.apply(applyTo);
  • 44. 44COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 44 JsonMergePatch { "firstName": "John", "lastName": "Doe", "age": 42 } { "firstName": "John", "lastName": " ", "address": " " } { "lastName": ”Doe", "age": 42, "address": null } Source Patch Result
  • 45. COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 45 Jakarta JSON Binding
  • 46. 46COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 46 Jakarta JSON Binding ● API to serialize/deserialize Java objects to/from JSON documents ○ Similar to JAX-B, except with JSON instead of XML ○ Standardizes features of the current technologies (Jackson, Genson, Gson) ● Easily convert between Java classes and JSON data with convenient default settings ● Customization APIs ○ Annotations (@JsonbProperty, @JsonbNillable) ○ Runtime configuration builder ● Natural follow on to JSON-P ○ Closes the JSON support gap ○ Allows to use different JSONP providers
  • 47. 47COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 47 Jakarta JSON Binding ● Web Site ○ https://eclipse-ee4j.github.io/jsonb-api/ ● Repository ○ https://github.com/eclipse-ee4j/jsonb-api ● Eclipse Project ○ https://projects.eclipse.org/projects/ee4j.jsonb ● Mailing List ○ https://accounts.eclipse.org/mailing-list/jsonb-dev
  • 48. COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 48 Default Mapping
  • 49. 49COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 49 Default Mapping ● No configuration, no annotations ● The scope: ○ Basic Types ○ Specific JDK Types ○ Dates ○ Classes ○ Collections/Arrays ○ Enumerations ○ JSON-P model classes import javax.json.bind.Jsonb; import javax.json.bind.JsonbBuilder; // Create with default config // Cache it! Jsonb jsonb = JsonbBuilder.create();
  • 50. 50COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 50 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); }
  • 51. 51COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 51 JSON-B Sample Person person1 = new Person(); person1.setFirstName("John"); person1.setLastName(”Doe"); person1.setAge(42); Person person2 = new Person(); person2.setFirstName("Jane"); person2.setLastName(”Doe"); person2.setAge(35); List<Person> persons = new ArrayList<>(); persons.add(person1); persons.add(person2); Jsonb jsonb = JsonbBuilder.create(); jsonb.toJson(persons); [ { "firstName": "John", "lastName": "Doe", "age": 42 }, { "firstName": "Jane", "lastName": "Doe", "age": 35 } ]
  • 52. 52COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 52 Basic and Specific Types 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
  • 53. 53COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 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 53 Date / Time
  • 54. 54COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 54 Data / Time Samples // java.util.Date SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy"); Date parsedDate = sdf.parse("10.09.2019"); jsonb.toJson(parsedDate)); // ”2019-09-10T00:00:00" // java.util.Calendar Calendar dateCalendar = Calendar.getInstance(); dateCalendar.clear(); dateCalendar.set(2019, 9, 10); jsonb.toJson(dateCalendar); // ”2019-09-10” // java.time.Instant jsonb.toJson(Instant.parse("2019-09-10T23:00:00Z")); // ”2019-09-10T23: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"
  • 55. 55COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 55 Arrays / Collections ● Collection ● Map ● Set ● HashSet ● NavigableSet ● SortedSet ● TreeSet ● LinkedHashSet ● TreeHashSet ● HashMap ● NavigableMap ● SortedMap ● TreeMap ● LinkedHashMap ● TreeHashMap ● List ● ArrayList ● LinkedList ● Deque ● ArrayDeque ● Queue ● PriorityQueue ● EnumSet (JSONB.next) ● EnumMap (JSONB.next)
  • 56. 56COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 56 JSON-P Types ● JsonValue ● JsonPointer ● JsonString ● JsonNumber ● JsonObject ● JsonArray ● JsonStructure // JsonObject JsonBuilderFactory f = Json.createBuilderFactory(null); JsonObject jsonObject = f.createObjectBuilder() .add(“firstName", "John") .add(“lastName", "Doe") .build(); String json = jsonb.toJson(jsonObject);
  • 57. 57COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 57 Classes ● Public and protected nested and static nested classes ● Anonymous classes (serialization only) ● Inheritance is supported ● Default no-argument constructor is required for default deserialization
  • 58. 58COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 58 Fields ● Final fields are serialized ● Static fields are skipped ● Transient fields are skipped ● Null fields are skipped ● Fields order ○ Lexicographical (A-Z) order ○ Parent class fields are serialized before child class fields
  • 59. 59COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 59 Field Order Sample public class Parent { public int parentB; public int parentA; } { "parentA": 1, "parentB": 2 }
  • 60. 60COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 60 Field Order Sample 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 }
  • 61. 61COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 61 Scope and Field Access Strategy 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
  • 62. 62COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 62 Scope and Field Access Strategy { "publicFinalField": 1, "publicWithNoGetter": 1, "privateWithPublicGetter": 1, "noField": 1 } 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) {}; }
  • 63. COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 63 Customized Mapping
  • 64. 64COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 64 JSON-B Engine Configuration ● Annotations ● Runtime configuration ○ JsonbConfig ○ JsonbBuilder JsonbConfig config = new JsonbConfig() .withFormatting(…) .withNullValues(…) .withEncoding(…) .withStrictIJSON(…) .withPropertyNamingStrategy(…) .withPropertyOrderStrategy(…) .withPropertyVisibilityStrategy(…) .withAdapters(…) .withBinaryDataStrategy(…); Jsonb jsonb = JsonbBuilder.newBuilder() .withConfig(…) .withProvider(…) .build();
  • 65. 65COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 65 Customizations ● Property names ● Property order ● Ignoring properties ● Null handling ● Custom instantiation ● Property visibility ● Date/Number Formats ● Binary Encoding ● Adapters ● Serializers/Deserializers
  • 66. 66COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 66 Property Names ● Annotation ○ @JsonbProperty ● Scope: ○ Field ○ Getter/Setter ○ Parameter public class Customer { public int id; @JsonbProperty("name") public String firstName; } public class Customer { public int id; private String firstName; @JsonbProperty("name") public String getFirstName() { return firstName; } }
  • 67. 67COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 67 Property Naming Strategy ● Globally changes the way of naming properties ● Supported a set of predefined strategies (see next slide) ○ JsonbConfig. withPropertyNamingStrategy(String strategyName) ● Ability to write your own strategy ○ Implement PropertyNamingStrategy interface ○ JsonbConfig. withPropertyNamingStrategy(PropertyNamingStrategy name);
  • 68. 68COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 68 Predefined Property Naming Strategies Strategy Name Sample IDENTITY (default) myProperty → myProperty LOWER_CASE_WITH_DASHES myProperty → my-property LOWER_CASE_WITH_UNDERSCORES myProperty → my_property UPPER_CAMEL_CASE myProperty → MyProperty UPPER_CAMEL_CASE_WITH_SPACES myProperty → "My Property" CASE_INSENSITIVE the same as IDENTITY but ignores case on deserialization Custom Strategy Custom case conversion login
  • 69. 69COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 69 Property Order Strategy ● Strategies: ○ LEXICOGRAPHICAL (A-Z) ○ ANY ○ REVERSE (Z-A) ● Annotation ○ @JsonbPropertyOrder on class ● JsonbConfig ○ withPropertyOrderStrategy(…) @JsonbPropertyOrder(ANY) public class Foo { public int bar2; public int bar1; }
  • 70. 70COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 70 Ignoring Properties ● Annotation ○ @JsonbTransient public class Foo { public int bar2; @JsonbTransient public int bar1; }
  • 71. 71COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 71 Property Visibility ● PropertyVisibilityStrategy interface ● Annotation ○ @JsonbVisibility ● JsonbConfig ○ withPropertyVisibilityStrategy(…) 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; }
  • 72. 72COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 72 Null Handling ● Null fields are skipped by default ● Annotation ○ @JsonbNillable ● JsonbConfig ○ withNullValues(true) public class Customer { public int id = 1; @JsonbProperty(nillable=true) public String name = null; } @JsonbNillable public class Customer { public int id = 1; public String name = null; }
  • 73. 73COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 73 Custom Instantiation public class Order { public int id; public Customer customer; } public class Customer { ... @JsonbCreator public static Customer getFromDb( @JsonbProperty int id) { return CustomerDao.getByPrimaryKey(id); } } { "id": 123, "customer": { "id": 562, } } ● Use @JsonbCreator when a class does not have a default (no-args) constructor ● At most one @JsonbCreator can be used per class ● Can be used on a constructor or static creator method
  • 74. 74COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 74 Date / Number Format ● Annotations ○ @JsonbDateFormat ○ @JsonbNumberFormat ● JsonbConfig ○ withDateFormat(…) ○ withLocale(…) public class FormatSample { public Date defaultDate; @JsonbDateFormat("dd.MM.yyyy") public Date formattedDate; public BigDecimal defaultNumber; @JsonbNumberFormat(“#0.00") public BigDecimal formattedNumber; }
  • 75. 75COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 75 Binary Data Encoding ● Supported encodings ○ BYTE (default) ○ BASE_64 ○ BASE_64_URL ● JsonbConfig ○ withBinaryDataStrategy(…) JsonbConfig config = new JsonbConfig() .withBinaryDataStrategy( BinaryDataStrategy.BASE_64); Jsonb jsonb = JsonbBuilder.create(config); String json = jsonb.toJson(obj);
  • 76. 76COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 76 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)
  • 77. 77COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 77 Adapters ● Inspired by JAXB ● Annotations ○ @JsonbTypeAdapter annotation ● JsonbConfig ○ withAdapters(…) 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());
  • 78. 78COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 78 Adapters ● Inspired by JAXB ● Annotations ○ @JsonbTypeAdapter annotation ● JsonbConfig ○ withAdapters(…) 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());
  • 79. 79COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 79 Serializers / Deserializers ● Low level control on serialization/deserialization ● Annotations ○ @JsonbTypeSerializer ○ @JsonbTypeDeserializer ● JsonbConfig ○ withSerializers(…) ○ withDeserializers(…) 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());
  • 80. COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 80 Plans
  • 81. 81COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 81 Future JSON-B Plans ● Larger features ○ Customize 3rd party classes (jsonb-api #88) ○ Polymorphic [De]serialization (jsonb-api #147) ○ Map directly to/from JsonGenerator and JsonParser (jsonb-api #122) ● Smaller features ○ Using @JsonbCreator with absent/optional fields (jsonb-api #121) ○ Configurable interface  impl mappings (jsonb-api #65) ○ Automatically register Adapters/[De]Serializers (jsonb-api #35) ○ Opt out of the “must ignore” policy (jsonb-api #56) ○ Customize date formats of different types (jsonb-api #87)
  • 82. 82COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 82 Customizing 3rd party classes ● Be able to customize classes you cannot modify ● Similar use-case as Jackson mix-ins // Cannot modify this class // Comes from 3rd party dependency public class Dog { // @JsonbProperty(“dogName”) public String name; public int age; // @JsonbTransient public Owner owner; } ClassCustomization c = ClassCustomization.for(Dog.class) .property(”name”, ”dogName”) .transient(”owner”) // The ”age” property not mentioned, so it is left as-is .build(); JsonbConfig config = new JsonbConfig() .withClassCustomization(c);
  • 83. 83COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 83 Polymorphic [de]serialization ● Allows for properties in the JSON data to be used to determine the Java deserialization class ● Highly requested feature, but security sensitive PolymorphicConfig poly = PolymorphicConfig.builder() .withClasses(Dog.class, Cat.class) .withTypeAttribute(”jsonb_class”); // optional JsonbConfig config = new JsonbConfig() .withPolymorphicConfig(poly); { ”jsonb_class": ”com.foo.Dog” ”name": ”Spot” ”bites": false } { ”jsonb_class": ”com.foo.Cat” ”name": ”Princess” ”meows": true }
  • 84. 84COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 84 Custom constructors with absent parameters ● JSON-B classes can have at most 1 @JsonbCreator annotated constructor ● Object might need to be constructed without some properties present ● Particularly useful for immutable data objects public class Person { public final String firstName; public final String middleName; public final String lastName; @JsonbCreator public Person( @JsonbCreator(”firstName”) String first, @JsonbCreator(”middleName”) String mid, @JsonbCreator(”lastName”) String last) { this.firstName = first; this.middleName = mid; this.lastName = last; } }{ "firstName": "Jane", "lastName": "Doe" }
  • 85. 85COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 85 Automatically register Adapters and [De]Serializers ● Add new annotations to automatically register JsonbAdapter, JsonbSerializer, and JsonbDeserializer when CDI is present ● No need to manually register objects with JsonbConfig @RegisterJsonbAdapter public class PersonAdapter implements JsonbAdapter<Person, Map<String,Object>> { // ... } JsonbConfig config = new JsonbConfig() .withAdapters(new PersonAdapter());
  • 86. 86COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 86 Opt-out of the ”Must-Ignore” policy ● By default JSON-B will ignore unrecognized properties on deserialization ● Provide way to opt-out so an error is raised if unrecognized properties are encountered { ”first": "Jane", ”last": "Doe" } JsonbConfig config = new JsonbConfig() .withAllowUnrecognized(false); // ... // Fails with JsonbException because // ‘first’ and ‘last’ properties not recognized Person p = jsonb.fromJson(json, Person.class) public class Person { public String firstName; public String middleName; public String lastName; }
  • 87. 87COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 87 Future JSON-B Plans ● See Github project board for complete overview and up-to-date information https://github.com/eclipse-ee4j/jsonb-api/projects/1
  • 88. COPYRIGHT (C) 2019, ECLIPSE FOUNDATION, INC. | MADE AVAILABLE UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 88 Thank you!