SlideShare a Scribd company logo
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Introduction to Yasson
Dmitry Kornilov
JSONB Spec Lead
@m0mus
26 Oct 2017
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Safe Harbor Statement
The following is intended to outline our general product direction. It is intended for
information purposes only, and may not be incorporated into any contract. It is not a
commitment to deliver any material, code, or functionality, and should not be relied upon
in making purchasing decisions. The development, release, and timing of any features or
functionality described for Oracle’s products remains at the sole discretion of Oracle.
2
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 3
Dmitry Kornilov
• Senior Manager @ Oracle
• JSON-B (JSR-367) spec lead
• JSON-P (JSR-374) spec lead
• Outstanding Spec Lead 2016
• EclipseLink project committer
• EE4J PMC Member
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Program Agenda
JSON Technologies in Java EE 8
JSON Binding
Yasson
Q & A
1
2
3
5
4
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
JSON Technologies in Java EE 8
5
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 6
What is JSON???
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
This is Jason
7
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
This is also Jason
8
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
What is JSON?
• JavaScript Object Notation
• Subset of JavaScript
• Lightweight data-interchange format
• Object, Array, Value
9
{
"name": "Jason Bourne",
"age": 35,
"phoneNumbers": [
{
"type": "home",
"number": "123-456-789"
}
]
}
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
JSON Support in Java EE 8
• JSON Processing API
– Standard API to parse, generate, transform, query JSON
– Object Model and Streaming API
• similar to DOM and StAX
• JSON Binding API
– Binding JSON documents to Java objects
• similar to JAXB
10
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
JSON Binding
11
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
JSON-B Links
• Official web: http://json-b.net
• GitHub repo: https://github.com/javaee/jsonb-spec
• Issues Tracker: https://github.com/javaee/jsonb-spec/issues
• JCP page: https://www.jcp.org/en/jsr/detail?id=367
• Groups: https://javaee.groups.io/g/jsonb-spec
12
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
JSON Binding
• API to serialize/deserialize Java objects to/from JSON documents
– Similar to JAX-B
– Standardizes the current technologies (Jackson, Genson, Gson)
• Default mapping between classes and JSON
• Customization APIs
– Annotations (@JsonbProperty, @JsonbNillable)
– Runtime configuration builder
• Natural follow on to JSON-P
– Closes the JSON support gap
– Allows to change providers
13
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
• JSON-B (JSON Binding)
– API and Specification
– JSR-367
– Part of Java EE 8
14
JSON-B and Yasson
• Yasson
– Reference Implementation
– Eclipse Foundation Project
– Part of GlassFish 5
– Part of WAS Liberty
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Yasson
15
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Yasson Links
• Web site: https://projects.eclipse.org/projects/rt.yasson
• GitHub repo: https://github.com/eclipse/yasson
• Issues Tracker: https://github.com/eclipse/yasson/issues
16
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Maven Dependencies
17
<!-- JSON-B API -->
<dependency>
<groupId>javax.json.bind</groupId>
<artifactId>javax.json.bind-api</artifactId>
<version>1.0</version>
</dependency>
<!-- Yasson (JSON-B RI) -->
<dependency>
<groupId>org.eclipse</groupId>
<artifactId>yasson</artifactId>
<version>1.0</version>
</dependency>
<repositories>
<repository>
<id>Yasson Snapshots</id>
<url>https://repo.eclipse.org/content/repositories/
yasson-snapshots/</url>
</repository>
</repositories>
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
• No configuration, no annotations
• The scope:
– Basic Types
– Specific JDK Types
– Dates
– Classes
– Collections/Arrays
– Enumerations
– JSON-P
18
Default Mapping
import javax.json.bind.Jsonb;
import javax.json.bind.JsonbBuilder;
// Create with default config
Jsonb jsonb = JsonbBuilder.create();
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 19
JSON-B Engine
public interface Jsonb extends AutoCloseable {
<T> T fromJson(String str, Class<T> type);
<T> T fromJson(String str, Type runtimeType);
<T> T fromJson(Reader reader, Class<T> type);
<T> T fromJson(Reader reader, Type runtimeType);
<T> T fromJson(InputStream stream, Class<T> type);
<T> T fromJson(InputStream stream, Type runtimeType);
String toJson(Object object);
String toJson(Object object, Type runtimeType);
void toJson(Object object, Writer writer);
void toJson(Object object, Type runtimeType, Writer writer);
void toJson(Object object, OutputStream stream);
void toJson(Object object, Type runtimeType, OutputStream stream);
}
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
JSON-B Sample
20
Person person1 = new Person();
person1.setName("Jason Voorhees");
person1.setProfession("Maniac killer");
person1.setAge(45);
Person person2 = new Person();
person2.setName("Jason Bourne");
person2.setProfession("Super agent");
person2.setAge(35);
List<Person> persons = new ArrayList<>();
persons.add(person1);
persons.add(person2);
Jsonb jsonb = JsonbBuilder.create();
jsonb.toJson(persons);
[
{
"name": "Jason Voorhees",
"profession": "Maniac killer",
"age": 45
},
{
"name": "Jason Bourne",
"profession": "Super agent",
"age": 35
}
]
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Basic Types
– java.lang.String
– java.lang.Character
– java.lang.Byte (byte)
– java.lang.Short (short)
– java.lang.Integer (int)
– java.lang.Long (long)
– java.lang.Float (float)
– java.lang.Double (double)
– java.lang.Boolean (boolean)
Specific Types
– java.math.BigInteger
– java.math.BigDecimal
– java.net.URL
– java.net.URI
– java.util.Optional
– java.util.OptionalInt
– java.util.OptionalLong
– java.util.OptionalDouble
21
Basic and Specific Types
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Date/Time
22
java.util.Date ISO_DATE_TIME
java.util.Calendar, java.util.GregorianCalendar ISO_DATE if to time information present, otherwise ISO_DATE_TIME
Java.util.TimeZone, java.util.SimpleTimeZone NormalizedCustomId (see TimeZone javadoc)
java.time.Instant ISO_INSTANT
java.time.LocalDate ISO_LOCAL_DATE
java.time.LocalTime ISO_LOCAL_TIME
java.time.LocalDateTime ISO_LOCAL_DATE_TIME
java.time.ZonedDateTime ISO_ZONED_DATE_TIME
java.time.OffsetDateTime ISO_OFFSET_DATE_TIME
java.time.OffsetTime ISO_OFFSET_TIME
java.time.ZoneId NormalizedZoneId as specified in ZoneId javadoc
java.time.ZoneOffset NormalizedZoneId as specified in ZoneOffset javadoc
java.time.Duration ISO 8601 seconds based representation
java.time.Period ISO 8601 period representation
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Date/Time Samples
23
// java.util.Date
SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy");
Date parsedDate = sdf.parse("15.11.2016");
jsonb.toJson(parsedDate)); // ”2016-11-15T00:00:00"
// java.util.Calendar
Calendar dateCalendar = Calendar.getInstance();
dateCalendar.clear();
dateCalendar.set(2016, 11, 15);
jsonb.toJson(dateCalendar); // ”2016-11-15”
// java.time.Instant
jsonb.toJson(Instant.parse("2016-11-15T23:00:00Z")); // ”2016-11-15T23:00:00Z”
// java.time.Duration
jsonb.toJson(Duration.ofHours(5).plusMinutes(4)); // “PT5H4M"
// java.time.Period
jsonb.toJson(Period.between(
LocalDate.of(1960, Month.JANUARY, 1),
LocalDate.of(1970, Month.JANUARY, 1))); // "P10Y"
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Arrays/Collections
• Collection
• Map
• Set
• HashSet
• NavigableSet
• SortedSet
• TreeSet
• LinkedHashSet
• HashMap
• NavigableMap
• SortedMap
• TreeMap
• LinkedHashMap
• List
• ArrayList
• LinkedList
• Deque
• ArrayDeque
• Queue
• PriorityQueue
24
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
• javax.json.JsonArray
• javax.json.JsonStructure
• javax.json.JsonValue
• javax.json.JsonPointer
• javax.json.JsonString
• javax.json.JsonNumber
• javax.json.JsonObject
25
JSON-P Types
// JsonObject
JsonBuilderFactory f =
Json.createBuilderFactory(null);
JsonObject jsonObject =
f.createObjectBuilder()
.add(“name", "Jason Bourne")
.add(“city", "Prague")
.build();
jsonb.toJson(jsonObject);
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Classes
• Public and protected static nested classes
• Anonymous classes (serialization only)
• Inheritance is supported
• Default no-argument constructor is required for deserialization
26
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Fields
• Final fields are serialized
• Static fields are skipped
• Transient fields are skipped
• Null fields are skipped
• Fields order
– Lexicographical order
– Parent class fields are serialized before child class fields
27
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
public class Parent {
public int parentB;
public int parentA;
}
{
"parentA": 1,
"parentB": 2
}
28
Fields Order Sample
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
public class Parent {
public int parentB;
public int parentA;
}
public class Child extends Parent {
public int childB;
public int childA;
}
{
"parentA": 1,
"parentB": 2
}
{
"parentA": 1,
"parentB": 2,
"childA": 3,
"childB": 4
}
29
Fields Order Sample
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Serialization
• Existing fields with public getters
• Public fields with no getters
• Public getter/setter pair without a
corresponding field
Deserialization
• Existing fields with public setters
• Public fields with no setters
• Public getter/setter pair without a
corresponding field
30
Scope and Field Access Strategy
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
public class Foo {
public final int publicFinalField;
private final int privateFinalField;
public static int publicStaticField;
public int publicWithNoGetter;
public int publicWithPrivateGetter;
public Integer publicNullField = null;
private int privateWithNoGetter;
private int privateWithPublicGetter;
public int getNoField() {};
public void setNoField(int value) {};
}
{
"publicFinalField": 1,
"publicWithNoGetter": 1,
"privateWithPublicGetter": 1,
"noField": 1
}
31
Scope and Field Access Strategy
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
• Annotations
• Runtime configuration
– JsonbConfig
– JsonbBuilder
32
Yasson Configuration
JsonbConfig config = new JsonbConfig()
.withFormatting(…)
.withNullValues(…)
.withEncoding(…)
.withStrictIJSON(…)
.withPropertyNamingStrategy(…)
.withPropertyOrderStrategy(…)
.withPropertyVisibilityStrategy(…)
.withAdapters(…)
.withBinaryDataStrategy(…);
Jsonb jsonb = JsonbBuilder.newBuilder()
.withConfig(…)
.withProvider(…)
.build();
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 33
Customizations
• Property names
• Property order
• Ignoring properties
• Null handling
• Custom instantiation
• Fields visibility
• Date/Number Formats
• Binary Encoding
• Adapters
• Serializers/Deserializers
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
• Annotation
– @JsonbProperty
• Scope:
– Field
– Getter/Setter
– Parameter
34
Property Names
public class Customer {
private int id;
@JsonbProperty("name")
public String firstName;
}
public class Customer {
public int id;
public String firstName;
@JsonbProperty("name")
public String getFirstName() {
return firstName;
}
}
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Property Naming Strategy
• Supported naming strategies
– IDENTITY (myMixedCaseProperty)
– LOWER_CASE_WITH_DASHES (my-mixed-case-property)
– LOWER_CASE_WITH_UNDERSCORES (my_mixed_case_property)
– UPPER_CAMEL_CASE (MyMixedCaseProperty)
– UPPER_CAMEL_CASE_WITH_SPACES (My Mixed Case Property)
– CASE_INSENSITIVE (mYmIxEdCaSePrOpErTy)
– Or a custom implementation
• JsonbConfig
– withPropertyNamingStrategy(…):
35
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
• Strategies:
– LEXICOGRAPHICAL (A-Z)
– ANY
– REVERSE (Z-A)
• Annotation
– @JsonbPropertyOrder on class
• JsonbConfig
– withPropertyOrderStrategy(…)
36
Property Order Strategy
@JsonbPropertyOrder("bar2", "bar1")
public class Foo {
public int bar2;
public int bar1;
}
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
• Annotation
– @JsonbTransient
37
Ignoring Properties
public class Customer {
public int id;
public String name;
@JsonbTransient
public BigDecimal salary;
}
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
• PropertyVisibilityStrategy
interface
• Annotation
– @JsonbVisibility
• JsonbConfig
– withPropertyVisibilityStrategy(…)
38
Property Visibility
public interface PropertyVisibilityStrategy {
boolean isVisible(Field field);
boolean isVisible(Method method);
}
public class MyStrategy implements
PropertyVisibilityStrategy {
/* ... */
}
@JsonbVisibility(MyStrategy.class)
public class Bar {
private int field1;
private int field2;
}
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
• Null fields are skipped by default
• Annotation
– @JsonbNillable
• JsonbConfig
– withNullValues(true)
39
Null Handling
public class Customer {
public int id = 1;
@JsonbProperty("name", true)
public String name = null;
}
@JsonbNillable
public class Customer {
public int id = 1;
public String name = null;
}
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Custom Instantiation
40
public class Customer {
public String name;
@JsonbCreator
public static Customer create(
@JsonbProperty("id") int id) {
return CustomerDao.getByPrimaryKey(id);
}
}
public class Order {
public int id;
public Customer customer;
}
{
"id": 123,
"customer": {
"id": 562,
}
}
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
• Annotations
– @JsonbDateFormat
– @JsonbNumberFormat
• JsonbConfig
– withDateFormat(…)
– withLocale(…)
41
Date/Number Format
public class FormatSample {
public Date defaultDate;
@JsonbDateFormat("dd.MM.yyyy")
public Date formattedDate;
public BigDecimal defaultNumber;
@JsonbNumberFormat(“#0.00")
public BigDecimal formattedNumber;
}
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
• Supported encodings
– BYTE (default)
– BASE_64
– BASE_64_URL
• JsonbConfig
– withBinaryDataStrategy(…)
42
Binary Data Encoding
JsonbConfig config = new JsonbConfig()
.withBinaryDataStrategy(
BinaryDataStrategy.BASE_64);
Jsonb jsonb = JsonbBuilder.create(config);
String json = jsonb.toJson(obj);
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
I-JSON
• I-JSON (”Internet JSON”) is a restricted profile of JSON
– https://tools.ietf.org/html/draft-ietf-json-i-json-06
• JSON-B fully supports I-JSON by default with three exceptions:
– JSON Binding does not restrict the serialization of top-level JSON texts that are
neither objects nor arrays. The restriction should happen at application level.
– JSON Binding does not serialize binary data with base64url encoding.
– JSON Binding does not enforce additional restrictions on dates/times/duration.
• JsonbConfig
– withStrictIJSON(true)
43
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
• Inspired by JAXB
• Annotations
– @JsonbTypeAdapter annotation
• JsonbConfig
– withAdapters(…)
44
Adapters
public interface JsonbAdapter<Original, Adapted> {
Adapted adaptToJson(Original obj);
Original adaptFromJson(Adapted obj);
}
@JsonbTypeAdapter(AnimalAdapter.class)
public Animal animal;
JsonbConfig config = new JsonbConfig()
.withAdapters(new AnimalAdapter());
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
• Low level control on
serialization/deserialization
• Annotations
– @JsonbTypeSerializer
– @JsonbTypeDeserializer
• JsonbConfig
– withSerializers(…)
– withDeserializers(…)
45
Serializers/Deserializers
public interface JsonbSerializer<T> {
void serialize(T obj, JsonGenerator generator,
SerializationContext ctx);
public interface JsonbDeserializer<T> {
T deserialize(JsonParser parser,
DeserializationContext ctx, Type rtType);
}
@JsonbTypeSerializer(AnimalSerializer.class)
@JsonbTypeDeserializer(AnimalDeserializer.class)
public Animal animal;
JsonbConfig config = new JsonbConfig()
.withSerializers(new AnimalSerializer())
.withDeserializers(new AnimalDeserializer());
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
JSON-B Demo
• GitHub
– https://github.com/m0mus/json_demo
• Demonstrates
– JSON-P
• JsonParser
• JsonGenerator
• Working with large files
• JsonPointer
• JsonPatch
• Using Java8 streams
46
– JSON-B
• Default mapping
• Adapters
• Serializers/Deserializers
• Mapping of generic class
• Using together with JSON-P
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Q & A
47
Introduction to Yasson

More Related Content

What's hot

Practical JSON in MySQL 5.7 and Beyond
Practical JSON in MySQL 5.7 and BeyondPractical JSON in MySQL 5.7 and Beyond
Practical JSON in MySQL 5.7 and Beyond
Ike Walker
 
Practical JSON in MySQL 5.7
Practical JSON in MySQL 5.7Practical JSON in MySQL 5.7
Practical JSON in MySQL 5.7
Ike Walker
 
DrupalCon Chicago Practical MongoDB and Drupal
DrupalCon Chicago Practical MongoDB and DrupalDrupalCon Chicago Practical MongoDB and Drupal
DrupalCon Chicago Practical MongoDB and Drupal
Doug Green
 
Webinar: Getting Started with MongoDB - Back to Basics
Webinar: Getting Started with MongoDB - Back to BasicsWebinar: Getting Started with MongoDB - Back to Basics
Webinar: Getting Started with MongoDB - Back to Basics
MongoDB
 
MongoDB (Advanced)
MongoDB (Advanced)MongoDB (Advanced)
MongoDB (Advanced)
TO THE NEW | Technology
 
CONFidence 2015: Fuzz your way into the web server's zoo - Andrey Plastunov
CONFidence 2015: Fuzz your way into the web server's zoo - Andrey PlastunovCONFidence 2015: Fuzz your way into the web server's zoo - Andrey Plastunov
CONFidence 2015: Fuzz your way into the web server's zoo - Andrey Plastunov
PROIDEA
 
Webinar: Working with Graph Data in MongoDB
Webinar: Working with Graph Data in MongoDBWebinar: Working with Graph Data in MongoDB
Webinar: Working with Graph Data in MongoDB
MongoDB
 
Sharding with MongoDB -- MongoDC 2012
Sharding with MongoDB -- MongoDC 2012Sharding with MongoDB -- MongoDC 2012
Sharding with MongoDB -- MongoDC 2012Tyler Brock
 
Mongo-Drupal
Mongo-DrupalMongo-Drupal
Mongo-Drupal
Forest Mars
 
Webinar: Building Your First App with MongoDB and Java
Webinar: Building Your First App with MongoDB and JavaWebinar: Building Your First App with MongoDB and Java
Webinar: Building Your First App with MongoDB and Java
MongoDB
 

What's hot (10)

Practical JSON in MySQL 5.7 and Beyond
Practical JSON in MySQL 5.7 and BeyondPractical JSON in MySQL 5.7 and Beyond
Practical JSON in MySQL 5.7 and Beyond
 
Practical JSON in MySQL 5.7
Practical JSON in MySQL 5.7Practical JSON in MySQL 5.7
Practical JSON in MySQL 5.7
 
DrupalCon Chicago Practical MongoDB and Drupal
DrupalCon Chicago Practical MongoDB and DrupalDrupalCon Chicago Practical MongoDB and Drupal
DrupalCon Chicago Practical MongoDB and Drupal
 
Webinar: Getting Started with MongoDB - Back to Basics
Webinar: Getting Started with MongoDB - Back to BasicsWebinar: Getting Started with MongoDB - Back to Basics
Webinar: Getting Started with MongoDB - Back to Basics
 
MongoDB (Advanced)
MongoDB (Advanced)MongoDB (Advanced)
MongoDB (Advanced)
 
CONFidence 2015: Fuzz your way into the web server's zoo - Andrey Plastunov
CONFidence 2015: Fuzz your way into the web server's zoo - Andrey PlastunovCONFidence 2015: Fuzz your way into the web server's zoo - Andrey Plastunov
CONFidence 2015: Fuzz your way into the web server's zoo - Andrey Plastunov
 
Webinar: Working with Graph Data in MongoDB
Webinar: Working with Graph Data in MongoDBWebinar: Working with Graph Data in MongoDB
Webinar: Working with Graph Data in MongoDB
 
Sharding with MongoDB -- MongoDC 2012
Sharding with MongoDB -- MongoDC 2012Sharding with MongoDB -- MongoDC 2012
Sharding with MongoDB -- MongoDC 2012
 
Mongo-Drupal
Mongo-DrupalMongo-Drupal
Mongo-Drupal
 
Webinar: Building Your First App with MongoDB and Java
Webinar: Building Your First App with MongoDB and JavaWebinar: Building Your First App with MongoDB and Java
Webinar: Building Your First App with MongoDB and Java
 

Similar to Introduction to Yasson

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
 
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
 
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 in Postgres - the Roadmap
 Json in Postgres - the Roadmap Json in Postgres - the Roadmap
Json in Postgres - the Roadmap
EDB
 
JSON-B for CZJUG
JSON-B for CZJUGJSON-B for CZJUG
JSON-B for CZJUG
Dmitry Kornilov
 
Java EE 8 Overview (Japanese)
Java EE 8 Overview (Japanese)Java EE 8 Overview (Japanese)
Java EE 8 Overview (Japanese)
Logico
 
JSON and the Oracle Database
JSON and the Oracle DatabaseJSON and the Oracle Database
JSON and the Oracle Database
Maria Colgan
 
Bas 5676-java ee 8 introduction
Bas 5676-java ee 8 introductionBas 5676-java ee 8 introduction
Bas 5676-java ee 8 introduction
Kevin Sutter
 
Java API for JSON Binding - Introduction and update
Java API for JSON Binding - Introduction and updateJava API for JSON Binding - Introduction and update
Java API for JSON Binding - Introduction and update
Martin Grebac
 
IPTC News in JSON Spring 2013
IPTC News in JSON Spring 2013IPTC News in JSON Spring 2013
IPTC News in JSON Spring 2013Stuart Myles
 
Jsquery - the jsonb query language with GIN indexing support
Jsquery - the jsonb query language with GIN indexing supportJsquery - the jsonb query language with GIN indexing support
Jsquery - the jsonb query language with GIN indexing support
Alexander Korotkov
 
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
 
Comparing JSON Libraries - July 19 2011
Comparing JSON Libraries - July 19 2011Comparing JSON Libraries - July 19 2011
Comparing JSON Libraries - July 19 2011
sullis
 
Json generation
Json generationJson generation
Json generation
Aravindharamanan S
 
Java JSON Parser Comparison
Java JSON Parser ComparisonJava JSON Parser Comparison
Java JSON Parser ComparisonAllan Huang
 
module 2.pptx for full stack mobile development application on backend applic...
module 2.pptx for full stack mobile development application on backend applic...module 2.pptx for full stack mobile development application on backend applic...
module 2.pptx for full stack mobile development application on backend applic...
HemaSenthil5
 
Java and JSON - UJUG - March 19 2009
Java and JSON - UJUG - March 19 2009Java and JSON - UJUG - March 19 2009
Java and JSON - UJUG - March 19 2009
sullis
 
Iasi code camp 12 october 2013 jax-rs-jee-ecosystem - catalin mihalache
Iasi code camp 12 october 2013   jax-rs-jee-ecosystem - catalin mihalacheIasi code camp 12 october 2013   jax-rs-jee-ecosystem - catalin mihalache
Iasi code camp 12 october 2013 jax-rs-jee-ecosystem - catalin mihalacheCodecamp Romania
 
XML-Free Programming : Java Server and Client Development without &lt;>
XML-Free Programming : Java Server and Client Development without &lt;>XML-Free Programming : Java Server and Client Development without &lt;>
XML-Free Programming : Java Server and Client Development without &lt;>
Arun Gupta
 

Similar to Introduction to Yasson (20)

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
 
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)
 
Json
JsonJson
Json
 
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 in Postgres - the Roadmap
 Json in Postgres - the Roadmap Json in Postgres - the Roadmap
Json in Postgres - the Roadmap
 
JSON-B for CZJUG
JSON-B for CZJUGJSON-B for CZJUG
JSON-B for CZJUG
 
Java EE 8 Overview (Japanese)
Java EE 8 Overview (Japanese)Java EE 8 Overview (Japanese)
Java EE 8 Overview (Japanese)
 
JSON and the Oracle Database
JSON and the Oracle DatabaseJSON and the Oracle Database
JSON and the Oracle Database
 
Bas 5676-java ee 8 introduction
Bas 5676-java ee 8 introductionBas 5676-java ee 8 introduction
Bas 5676-java ee 8 introduction
 
Java API for JSON Binding - Introduction and update
Java API for JSON Binding - Introduction and updateJava API for JSON Binding - Introduction and update
Java API for JSON Binding - Introduction and update
 
IPTC News in JSON Spring 2013
IPTC News in JSON Spring 2013IPTC News in JSON Spring 2013
IPTC News in JSON Spring 2013
 
Jsquery - the jsonb query language with GIN indexing support
Jsquery - the jsonb query language with GIN indexing supportJsquery - the jsonb query language with GIN indexing support
Jsquery - the jsonb query language with GIN indexing support
 
JSON Support in Java EE 8
JSON Support in Java EE 8JSON Support in Java EE 8
JSON Support in Java EE 8
 
Comparing JSON Libraries - July 19 2011
Comparing JSON Libraries - July 19 2011Comparing JSON Libraries - July 19 2011
Comparing JSON Libraries - July 19 2011
 
Json generation
Json generationJson generation
Json generation
 
Java JSON Parser Comparison
Java JSON Parser ComparisonJava JSON Parser Comparison
Java JSON Parser Comparison
 
module 2.pptx for full stack mobile development application on backend applic...
module 2.pptx for full stack mobile development application on backend applic...module 2.pptx for full stack mobile development application on backend applic...
module 2.pptx for full stack mobile development application on backend applic...
 
Java and JSON - UJUG - March 19 2009
Java and JSON - UJUG - March 19 2009Java and JSON - UJUG - March 19 2009
Java and JSON - UJUG - March 19 2009
 
Iasi code camp 12 october 2013 jax-rs-jee-ecosystem - catalin mihalache
Iasi code camp 12 october 2013   jax-rs-jee-ecosystem - catalin mihalacheIasi code camp 12 october 2013   jax-rs-jee-ecosystem - catalin mihalache
Iasi code camp 12 october 2013 jax-rs-jee-ecosystem - catalin mihalache
 
XML-Free Programming : Java Server and Client Development without &lt;>
XML-Free Programming : Java Server and Client Development without &lt;>XML-Free Programming : Java Server and Client Development without &lt;>
XML-Free Programming : Java Server and Client Development without &lt;>
 

More from Dmitry Kornilov

Helidon Nima - Loom based microserfice framework.pptx
Helidon Nima - Loom based microserfice framework.pptxHelidon Nima - Loom based microserfice framework.pptx
Helidon Nima - Loom based microserfice framework.pptx
Dmitry Kornilov
 
Jakarta EE: Today and Tomorrow
Jakarta EE: Today and TomorrowJakarta EE: Today and Tomorrow
Jakarta EE: Today and Tomorrow
Dmitry Kornilov
 
Building Cloud-Native Applications with Helidon
Building Cloud-Native Applications with HelidonBuilding Cloud-Native Applications with Helidon
Building Cloud-Native Applications with Helidon
Dmitry Kornilov
 
Nonblocking Database Access in Helidon SE
Nonblocking Database Access in Helidon SENonblocking Database Access in Helidon SE
Nonblocking Database Access in Helidon SE
Dmitry Kornilov
 
JSON Support in Jakarta EE: Present and Future
JSON Support in Jakarta EE: Present and FutureJSON Support in Jakarta EE: Present and Future
JSON Support in Jakarta EE: Present and Future
Dmitry Kornilov
 
Building cloud native microservices with project Helidon
Building cloud native microservices with project HelidonBuilding cloud native microservices with project Helidon
Building cloud native microservices with project Helidon
Dmitry Kornilov
 
Developing cloud-native microservices using project Helidon
Developing cloud-native microservices using project HelidonDeveloping cloud-native microservices using project Helidon
Developing cloud-native microservices using project Helidon
Dmitry Kornilov
 
From Java EE to Jakarta EE
From Java EE to Jakarta EEFrom Java EE to Jakarta EE
From Java EE to Jakarta EE
Dmitry Kornilov
 
Helidon: Java Libraries for Writing Microservices
Helidon: Java Libraries for Writing MicroservicesHelidon: Java Libraries for Writing Microservices
Helidon: Java Libraries for Writing Microservices
Dmitry Kornilov
 
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
 
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
 

More from Dmitry Kornilov (13)

Helidon Nima - Loom based microserfice framework.pptx
Helidon Nima - Loom based microserfice framework.pptxHelidon Nima - Loom based microserfice framework.pptx
Helidon Nima - Loom based microserfice framework.pptx
 
Jakarta EE: Today and Tomorrow
Jakarta EE: Today and TomorrowJakarta EE: Today and Tomorrow
Jakarta EE: Today and Tomorrow
 
Building Cloud-Native Applications with Helidon
Building Cloud-Native Applications with HelidonBuilding Cloud-Native Applications with Helidon
Building Cloud-Native Applications with Helidon
 
Nonblocking Database Access in Helidon SE
Nonblocking Database Access in Helidon SENonblocking Database Access in Helidon SE
Nonblocking Database Access in Helidon SE
 
JSON Support in Jakarta EE: Present and Future
JSON Support in Jakarta EE: Present and FutureJSON Support in Jakarta EE: Present and Future
JSON Support in Jakarta EE: Present and Future
 
Building cloud native microservices with project Helidon
Building cloud native microservices with project HelidonBuilding cloud native microservices with project Helidon
Building cloud native microservices with project Helidon
 
Developing cloud-native microservices using project Helidon
Developing cloud-native microservices using project HelidonDeveloping cloud-native microservices using project Helidon
Developing cloud-native microservices using project Helidon
 
From Java EE to Jakarta EE
From Java EE to Jakarta EEFrom Java EE to Jakarta EE
From Java EE to Jakarta EE
 
Helidon: Java Libraries for Writing Microservices
Helidon: Java Libraries for Writing MicroservicesHelidon: Java Libraries for Writing Microservices
Helidon: Java Libraries for Writing Microservices
 
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
 
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
 

Recently uploaded

UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
g2nightmarescribd
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 

Recently uploaded (20)

UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 

Introduction to Yasson

  • 1. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. Introduction to Yasson Dmitry Kornilov JSONB Spec Lead @m0mus 26 Oct 2017
  • 2. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. Safe Harbor Statement The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle. 2
  • 3. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 3 Dmitry Kornilov • Senior Manager @ Oracle • JSON-B (JSR-367) spec lead • JSON-P (JSR-374) spec lead • Outstanding Spec Lead 2016 • EclipseLink project committer • EE4J PMC Member
  • 4. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. Program Agenda JSON Technologies in Java EE 8 JSON Binding Yasson Q & A 1 2 3 5 4
  • 5. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. JSON Technologies in Java EE 8 5
  • 6. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 6 What is JSON???
  • 7. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. This is Jason 7
  • 8. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. This is also Jason 8
  • 9. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. What is JSON? • JavaScript Object Notation • Subset of JavaScript • Lightweight data-interchange format • Object, Array, Value 9 { "name": "Jason Bourne", "age": 35, "phoneNumbers": [ { "type": "home", "number": "123-456-789" } ] }
  • 10. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. JSON Support in Java EE 8 • JSON Processing API – Standard API to parse, generate, transform, query JSON – Object Model and Streaming API • similar to DOM and StAX • JSON Binding API – Binding JSON documents to Java objects • similar to JAXB 10
  • 11. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. JSON Binding 11
  • 12. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. JSON-B Links • Official web: http://json-b.net • GitHub repo: https://github.com/javaee/jsonb-spec • Issues Tracker: https://github.com/javaee/jsonb-spec/issues • JCP page: https://www.jcp.org/en/jsr/detail?id=367 • Groups: https://javaee.groups.io/g/jsonb-spec 12
  • 13. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. JSON Binding • API to serialize/deserialize Java objects to/from JSON documents – Similar to JAX-B – Standardizes the current technologies (Jackson, Genson, Gson) • Default mapping between classes and JSON • Customization APIs – Annotations (@JsonbProperty, @JsonbNillable) – Runtime configuration builder • Natural follow on to JSON-P – Closes the JSON support gap – Allows to change providers 13
  • 14. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. • JSON-B (JSON Binding) – API and Specification – JSR-367 – Part of Java EE 8 14 JSON-B and Yasson • Yasson – Reference Implementation – Eclipse Foundation Project – Part of GlassFish 5 – Part of WAS Liberty
  • 15. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. Yasson 15
  • 16. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. Yasson Links • Web site: https://projects.eclipse.org/projects/rt.yasson • GitHub repo: https://github.com/eclipse/yasson • Issues Tracker: https://github.com/eclipse/yasson/issues 16
  • 17. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. Maven Dependencies 17 <!-- JSON-B API --> <dependency> <groupId>javax.json.bind</groupId> <artifactId>javax.json.bind-api</artifactId> <version>1.0</version> </dependency> <!-- Yasson (JSON-B RI) --> <dependency> <groupId>org.eclipse</groupId> <artifactId>yasson</artifactId> <version>1.0</version> </dependency> <repositories> <repository> <id>Yasson Snapshots</id> <url>https://repo.eclipse.org/content/repositories/ yasson-snapshots/</url> </repository> </repositories>
  • 18. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. • No configuration, no annotations • The scope: – Basic Types – Specific JDK Types – Dates – Classes – Collections/Arrays – Enumerations – JSON-P 18 Default Mapping import javax.json.bind.Jsonb; import javax.json.bind.JsonbBuilder; // Create with default config Jsonb jsonb = JsonbBuilder.create();
  • 19. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 19 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); }
  • 20. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. JSON-B Sample 20 Person person1 = new Person(); person1.setName("Jason Voorhees"); person1.setProfession("Maniac killer"); person1.setAge(45); Person person2 = new Person(); person2.setName("Jason Bourne"); person2.setProfession("Super agent"); person2.setAge(35); List<Person> persons = new ArrayList<>(); persons.add(person1); persons.add(person2); Jsonb jsonb = JsonbBuilder.create(); jsonb.toJson(persons); [ { "name": "Jason Voorhees", "profession": "Maniac killer", "age": 45 }, { "name": "Jason Bourne", "profession": "Super agent", "age": 35 } ]
  • 21. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. Basic Types – java.lang.String – java.lang.Character – java.lang.Byte (byte) – java.lang.Short (short) – java.lang.Integer (int) – java.lang.Long (long) – java.lang.Float (float) – java.lang.Double (double) – java.lang.Boolean (boolean) Specific Types – java.math.BigInteger – java.math.BigDecimal – java.net.URL – java.net.URI – java.util.Optional – java.util.OptionalInt – java.util.OptionalLong – java.util.OptionalDouble 21 Basic and Specific Types
  • 22. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. Date/Time 22 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
  • 23. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. Date/Time Samples 23 // java.util.Date SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy"); Date parsedDate = sdf.parse("15.11.2016"); jsonb.toJson(parsedDate)); // ”2016-11-15T00:00:00" // java.util.Calendar Calendar dateCalendar = Calendar.getInstance(); dateCalendar.clear(); dateCalendar.set(2016, 11, 15); jsonb.toJson(dateCalendar); // ”2016-11-15” // java.time.Instant jsonb.toJson(Instant.parse("2016-11-15T23:00:00Z")); // ”2016-11-15T23:00:00Z” // java.time.Duration jsonb.toJson(Duration.ofHours(5).plusMinutes(4)); // “PT5H4M" // java.time.Period jsonb.toJson(Period.between( LocalDate.of(1960, Month.JANUARY, 1), LocalDate.of(1970, Month.JANUARY, 1))); // "P10Y"
  • 24. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. Arrays/Collections • Collection • Map • Set • HashSet • NavigableSet • SortedSet • TreeSet • LinkedHashSet • HashMap • NavigableMap • SortedMap • TreeMap • LinkedHashMap • List • ArrayList • LinkedList • Deque • ArrayDeque • Queue • PriorityQueue 24
  • 25. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. • javax.json.JsonArray • javax.json.JsonStructure • javax.json.JsonValue • javax.json.JsonPointer • javax.json.JsonString • javax.json.JsonNumber • javax.json.JsonObject 25 JSON-P Types // JsonObject JsonBuilderFactory f = Json.createBuilderFactory(null); JsonObject jsonObject = f.createObjectBuilder() .add(“name", "Jason Bourne") .add(“city", "Prague") .build(); jsonb.toJson(jsonObject);
  • 26. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. Classes • Public and protected static nested classes • Anonymous classes (serialization only) • Inheritance is supported • Default no-argument constructor is required for deserialization 26
  • 27. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. Fields • Final fields are serialized • Static fields are skipped • Transient fields are skipped • Null fields are skipped • Fields order – Lexicographical order – Parent class fields are serialized before child class fields 27
  • 28. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. public class Parent { public int parentB; public int parentA; } { "parentA": 1, "parentB": 2 } 28 Fields Order Sample
  • 29. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. public class Parent { public int parentB; public int parentA; } public class Child extends Parent { public int childB; public int childA; } { "parentA": 1, "parentB": 2 } { "parentA": 1, "parentB": 2, "childA": 3, "childB": 4 } 29 Fields Order Sample
  • 30. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. Serialization • Existing fields with public getters • Public fields with no getters • Public getter/setter pair without a corresponding field Deserialization • Existing fields with public setters • Public fields with no setters • Public getter/setter pair without a corresponding field 30 Scope and Field Access Strategy
  • 31. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. public class Foo { public final int publicFinalField; private final int privateFinalField; public static int publicStaticField; public int publicWithNoGetter; public int publicWithPrivateGetter; public Integer publicNullField = null; private int privateWithNoGetter; private int privateWithPublicGetter; public int getNoField() {}; public void setNoField(int value) {}; } { "publicFinalField": 1, "publicWithNoGetter": 1, "privateWithPublicGetter": 1, "noField": 1 } 31 Scope and Field Access Strategy
  • 32. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. • Annotations • Runtime configuration – JsonbConfig – JsonbBuilder 32 Yasson Configuration JsonbConfig config = new JsonbConfig() .withFormatting(…) .withNullValues(…) .withEncoding(…) .withStrictIJSON(…) .withPropertyNamingStrategy(…) .withPropertyOrderStrategy(…) .withPropertyVisibilityStrategy(…) .withAdapters(…) .withBinaryDataStrategy(…); Jsonb jsonb = JsonbBuilder.newBuilder() .withConfig(…) .withProvider(…) .build();
  • 33. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 33 Customizations • Property names • Property order • Ignoring properties • Null handling • Custom instantiation • Fields visibility • Date/Number Formats • Binary Encoding • Adapters • Serializers/Deserializers
  • 34. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. • Annotation – @JsonbProperty • Scope: – Field – Getter/Setter – Parameter 34 Property Names public class Customer { private int id; @JsonbProperty("name") public String firstName; } public class Customer { public int id; public String firstName; @JsonbProperty("name") public String getFirstName() { return firstName; } }
  • 35. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. Property Naming Strategy • Supported naming strategies – IDENTITY (myMixedCaseProperty) – LOWER_CASE_WITH_DASHES (my-mixed-case-property) – LOWER_CASE_WITH_UNDERSCORES (my_mixed_case_property) – UPPER_CAMEL_CASE (MyMixedCaseProperty) – UPPER_CAMEL_CASE_WITH_SPACES (My Mixed Case Property) – CASE_INSENSITIVE (mYmIxEdCaSePrOpErTy) – Or a custom implementation • JsonbConfig – withPropertyNamingStrategy(…): 35
  • 36. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. • Strategies: – LEXICOGRAPHICAL (A-Z) – ANY – REVERSE (Z-A) • Annotation – @JsonbPropertyOrder on class • JsonbConfig – withPropertyOrderStrategy(…) 36 Property Order Strategy @JsonbPropertyOrder("bar2", "bar1") public class Foo { public int bar2; public int bar1; }
  • 37. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. • Annotation – @JsonbTransient 37 Ignoring Properties public class Customer { public int id; public String name; @JsonbTransient public BigDecimal salary; }
  • 38. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. • PropertyVisibilityStrategy interface • Annotation – @JsonbVisibility • JsonbConfig – withPropertyVisibilityStrategy(…) 38 Property Visibility public interface PropertyVisibilityStrategy { boolean isVisible(Field field); boolean isVisible(Method method); } public class MyStrategy implements PropertyVisibilityStrategy { /* ... */ } @JsonbVisibility(MyStrategy.class) public class Bar { private int field1; private int field2; }
  • 39. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. • Null fields are skipped by default • Annotation – @JsonbNillable • JsonbConfig – withNullValues(true) 39 Null Handling public class Customer { public int id = 1; @JsonbProperty("name", true) public String name = null; } @JsonbNillable public class Customer { public int id = 1; public String name = null; }
  • 40. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. Custom Instantiation 40 public class Customer { public String name; @JsonbCreator public static Customer create( @JsonbProperty("id") int id) { return CustomerDao.getByPrimaryKey(id); } } public class Order { public int id; public Customer customer; } { "id": 123, "customer": { "id": 562, } }
  • 41. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. • Annotations – @JsonbDateFormat – @JsonbNumberFormat • JsonbConfig – withDateFormat(…) – withLocale(…) 41 Date/Number Format public class FormatSample { public Date defaultDate; @JsonbDateFormat("dd.MM.yyyy") public Date formattedDate; public BigDecimal defaultNumber; @JsonbNumberFormat(“#0.00") public BigDecimal formattedNumber; }
  • 42. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. • Supported encodings – BYTE (default) – BASE_64 – BASE_64_URL • JsonbConfig – withBinaryDataStrategy(…) 42 Binary Data Encoding JsonbConfig config = new JsonbConfig() .withBinaryDataStrategy( BinaryDataStrategy.BASE_64); Jsonb jsonb = JsonbBuilder.create(config); String json = jsonb.toJson(obj);
  • 43. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. I-JSON • I-JSON (”Internet JSON”) is a restricted profile of JSON – https://tools.ietf.org/html/draft-ietf-json-i-json-06 • JSON-B fully supports I-JSON by default with three exceptions: – JSON Binding does not restrict the serialization of top-level JSON texts that are neither objects nor arrays. The restriction should happen at application level. – JSON Binding does not serialize binary data with base64url encoding. – JSON Binding does not enforce additional restrictions on dates/times/duration. • JsonbConfig – withStrictIJSON(true) 43
  • 44. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. • Inspired by JAXB • Annotations – @JsonbTypeAdapter annotation • JsonbConfig – withAdapters(…) 44 Adapters public interface JsonbAdapter<Original, Adapted> { Adapted adaptToJson(Original obj); Original adaptFromJson(Adapted obj); } @JsonbTypeAdapter(AnimalAdapter.class) public Animal animal; JsonbConfig config = new JsonbConfig() .withAdapters(new AnimalAdapter());
  • 45. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. • Low level control on serialization/deserialization • Annotations – @JsonbTypeSerializer – @JsonbTypeDeserializer • JsonbConfig – withSerializers(…) – withDeserializers(…) 45 Serializers/Deserializers public interface JsonbSerializer<T> { void serialize(T obj, JsonGenerator generator, SerializationContext ctx); public interface JsonbDeserializer<T> { T deserialize(JsonParser parser, DeserializationContext ctx, Type rtType); } @JsonbTypeSerializer(AnimalSerializer.class) @JsonbTypeDeserializer(AnimalDeserializer.class) public Animal animal; JsonbConfig config = new JsonbConfig() .withSerializers(new AnimalSerializer()) .withDeserializers(new AnimalDeserializer());
  • 46. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. JSON-B Demo • GitHub – https://github.com/m0mus/json_demo • Demonstrates – JSON-P • JsonParser • JsonGenerator • Working with large files • JsonPointer • JsonPatch • Using Java8 streams 46 – JSON-B • Default mapping • Adapters • Serializers/Deserializers • Mapping of generic class • Using together with JSON-P
  • 47. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. Q & A 47