SlideShare a Scribd company logo
1 of 74
Download to read offline
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.
What’s new in JSR 367
Java API for JSON Binding
Dmitry Kornilov
EclipseLink MOXy & SDO Team Lead
Oracle Czech
dmitry.kornilov@oracle.com
Copyright © 2015, 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.
4
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 5
Program Agenda
1. What is JSONB?
2. JSR Status & Progress
3. What is in the spec
4. The Implementation (with demo)
5. What’s next
6. Q&A session
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 6
• JSON Binding is a standard
• JSON Binding = JSON-B = JSONB = JSR 367
• It’s about converting Java objects to and from JSON documents
What is JSON Binding?
6
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 7
What is JSON Binding?
7
public class Customer {
public int id;
public String firstName;
public String lastName;
….
}
Customer e = new Customer();
e.id = 1;
e.firstName = “John”;
e.lastName = “Doe”;
{
"id": 1,
"firstName" : "John",
"lastName" : "Doe",
}
Java JSON
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 88
Usage in Other Frameworks
JAX-RS
Objects
XML
JSON
JAXB
JSON-B
8
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
JSR Status & Progress
9
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 1010
JSR 367 Status
https://www.jcp.org/en/jsr/detail?id=367
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 1111
What’s Done in Last Year
• Finished experts group formation
• Early Draft published
• Reference implementation started
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 1212
Experts Group
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 1313
Early Draft
• Created 20 Aug 2015
• Published 19 Sep 2015
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 1414
Reference Implementation Started
First JSONB marshaller implementation
Signed-off-by: Dmitry Kornilov <dmitry.kornilov@oracle.com>
Reviewed-by: Martin Grebac, Lukas Jungmann
http://git.eclipse.org/c/eclipselink/eclipselink.runtime.git/log/
author Dmitry Kornilov 2015-09-14 09:06:06 (EDT)
committer Dmitry Kornilov 2015-09-14 09:06:18 (EDT)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 1515
Participate!

users@jsonb-spec.java.net
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
JSON-B Specification (Early Draft)
16
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 1717
Specification Project
• Project Home: 

https://java.net/projects/jsonb-spec/pages/Home
• Sources & samples: 

https://java.net/projects/jsonb-spec/sources/git/show/api
• Document (pdf): 

https://java.net/projects/jsonb-spec/sources/git/content/spec/spec.pdf
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 1818
JSON-B Runtime API
1. Create JSONB engine configuration (optional)
2. Create JSONB engine
3. Use it!
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 1919
JSON-B Engine Configuration
import javax.json.bind.JsonbConfig;
// JSON-B engine configuration
JsonbConfig config = new JsonbConfig()
.withFormatting(…)
.withNullValues(…)
.withEncoding(…)
.withStrictIJSON(…)
.withPropertyNamingStrategy(…)
.withPropertyOrderStrategy(…)
.withPropertyVisibilityStrategy(…)

.withAdapters()
.withBinaryDataStrategy(…);
• Configuration is optional
• Managed by one class
• Builder pattern is used
• Passed to JsonbBuilder
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 2020
JSON-B Engine
• Jsonb class
• Created by JsonbBuilder
• Ability to choose JSONP
provider
import javax.json.bind.Jsonb;
import javax.json.bind.JsonbBuilder;
// Create JSON-B engine
Jsonb jsonb = JsonbBuilder.newBuilder()

.withConfig(…)

.withProvider(…)

.build();
// Create with given config
Jsonb jsonb = JsonbBuilder.create(config);
// Create with default config
Jsonb jsonb = JsonbBuilder.create();
Copyright © 2015, Oracle and/or its affiliates. All rights reserved.
• toJson(…)
• fromJson(…)
2121
JSON-B Engine
String toJson(Object object);
String toJson(Object object, Type runtimeType);
void toJson(Object object, Appendable appendable);
void toJson(Object object, Type runtimeType, Appendable appendable);
void toJson(Object object, OutputStream stream);
void toJson(Object object, Type runtimeType, OutputStream stream);
<T> T fromJson(String str, Class<T> type);
<T> T fromJson(String str, Type runtimeType);
<T> T fromJson(Readable readable, Class<T> type);
<T> T fromJson(Readable readable, Type runtimeType);
<T> T fromJson(InputStream stream, Class<T> type);
<T> T fromJson(InputStream stream, Type runtimeType);
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 2222
Default Mapping
• Basic Types
• Specific Types
• Dates
• Classes
• Collections/Arrays
• Enumerations
• JSON-P
import javax.json.bind.Jsonb;
import javax.json.bind.JsonbBuilder;
// Create with default config
Jsonb jsonb = JsonbBuilder.create();
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 2323
• 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)
• java.lang.Number
Default Mapping - Basic Types
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 2424
• 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)
• java.lang.Number
Long longVal = Long.valueOf(1L);

String json = jsonb.toJson(longVal);

// Corresponding toString() method is used on serialization

json.equals(longVal.toString()); // true
Default Mapping - Basic Types
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 2525
• 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)
• java.lang.Number
Long longVal = Long.valueOf(1L);

String json = jsonb.toJson(longVal);

// Corresponding toString() method is used on serialization

json.equals(longVal.toString()); // true
// Corresponding parseX() method is used on deserialization

jsonb.fromJson(json, Long.class)
.equals(Long.parseLong(json)); // true
Default Mapping - Basic Types
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 2626
• 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)
• java.lang.Number
Long longVal = Long.valueOf(1L);

String json = jsonb.toJson(longVal);

// Corresponding toString() method is used on serialization

json.equals(longVal.toString()); // true
// Corresponding parseX() method is used on deserialization

jsonb.fromJson(json, Long.class)
.equals(Long.parseLong(json)); // true
jsonb.toJson("string"); // “string”
jsonb.toJson('uFFFF'); // "uFFFF"
jsonb.toJson((byte)1); // 1
jsonb.toJson((short)1); // 1
jsonb.toJson((int)1); // 1
jsonb.toJson(1L); // 1
jsonb.toJson(1.2f); // 1.2
jsonb.toJson(1.2); // 1.2
jsonb.toJson(true); // true
jsonb.toJson(null); // null
Default Mapping - Basic Types
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 2727
Default Mapping - 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
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 2828
Default Mapping - 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
BigDecimal bdVal = BigDecimal.valueOf(1.2);
String json = jsonb.toJson(bdVal); // 1.2

// Corresponding toString() method is used on serialization

json.equals(bdVal.toString()); // true
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 2929
Default Mapping - 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
BigDecimal bdVal = BigDecimal.valueOf(1.2);
String json = jsonb.toJson(bdVal); // 1.2

// Corresponding toString() method is used on serialization

json.equals(bdVal.toString()); // true
// Constructor with string argument is used on deserialization

jsonb.fromJson(json, BigDecimal.class)
.equals(new BigDecimal(1.2)); // true
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 3030
Default Mapping - 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
BigDecimal bdVal = BigDecimal.valueOf(1.2);
String json = jsonb.toJson(bdVal); // 1.2

// Corresponding toString() method is used on serialization

json.equals(bdVal.toString()); // true
// Constructor with string argument is used on deserialization

jsonb.fromJson(json, BigDecimal.class)
.equals(new BigDecimal(1.2)); // true
// OptionalInt
jsonb.toJson(OptionalInt.of(1)); // 1
jsonb.toJson(OptionalInt.empty()); // null
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 3131
Default Mapping - Dates
ISO_DATE
ISO_DATE_TIME
Java Type Format
java.util.Date ISO_DATE_TIME
java.util.Calendar ISO_DATE if to time information present, otherwise ISO_DATE_TIME
java.util.GregorianCalendar ISO_DATE if to time information present, otherwise ISO_DATE_TIME
java.util.TimeZone NormalizedCustomId (see TimeZone javadoc)
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 © 2015, Oracle and/or its affiliates. All rights reserved. 3232
// java.util.Date

SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy");

Date parsedDate = sdf.parse("25.10.2015");

jsonb.toJson(parsedDate)); // ”2015-10-25T00:00:00"
Default Mapping - Date Samples
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 3333
// java.util.Date

SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy");

Date parsedDate = sdf.parse("25.10.2015");

jsonb.toJson(parsedDate)); // ”2015-10-25T00:00:00"
// java.util.Calendar

Calendar dateCalendar = Calendar.getInstance();

dateCalendar.clear();

dateCalendar.set(2015, 10, 25);
jsonb.toJson(dateCalendar); // ”2015-10-25”
Default Mapping - Date Samples
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 3434
// java.util.Date

SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy");

Date parsedDate = sdf.parse("25.10.2015");

jsonb.toJson(parsedDate)); // ”2015-10-25T00:00:00"
// java.util.Calendar

Calendar dateCalendar = Calendar.getInstance();

dateCalendar.clear();

dateCalendar.set(2015, 10, 25);
jsonb.toJson(dateCalendar); // ”2015-10-25”
// java.time.Instant

jsonb.toJson(Instant.parse(“2015-10-25T23:00:00Z")); // ”2015-10-25T23: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"
Default Mapping - Date Samples
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 3535
Default Mapping - Classes
• Public and protected nested and static nested classes
• Anonymous classes (serialization only)
• Inheritance is supported
• Default no-argument constructor is required for deserialization
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 3636
Default Mapping - Fields
• Final fields are supported (serialization only)
• Static fields are not supported
• Transient fields are not supported
• Null fields are skipped
• Lexicographical order
• Parent class fields are serialized before child class fields
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 3737
Fields Order Sample
{ 

"parentA": 1,
"parentB": 2
}
public class Parent {

public int parentB;

public int parentA;

}
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 3838
Fields Order Sample
{ 

"parentA": 1,
"parentB": 2
}
{ 

"parentA": 1,
"parentB": 2,
"childA": 3,
"childB": 4
}
public class Parent {

public int parentB;

public int parentA;

}
public class Child extends Parent {

public int childB;

public int childA;

}
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 3939
Default Mapping - 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
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 4040
Scope and Field Access Strategy Sample
{ 

"publicFinalField": 1,
"publicFieldWithNoGetter": 1,
"privateFieldWithPublicGetter": 1,
"noField": 1,
}
public class Foo {
public final int publicFinalField;
private final int privateFinalField;
public static int publicStaticField;


public int publicFieldWithNoGetter;

public int publicFieldWithPrivateGetter;
public Integer publicNullField = null;
private int privateFieldWithNoGetter;
private int privateFieldWithPublicGetter;
public int getNoField() {};
public void setNoField(int value) {};

}
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 4141
// Array
int[] intArray = {1, 2, 3};


jsonb.toJson(intArray); // [1,2,3]
// Collection

Collection<Object> list = new ArrayList<>();

list.add(1);

list.add(2);
list.add(null);



jsonb.toJson(list); // [1,2,null]
// Map

Map<String, Object> map = new LinkedHashMap<>();

map.put("first", 1);

map.put("second", 2);



jsonb.toJson(map); // {"first":1,"second":2}
Default Mapping - 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
• EnumMap
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 4242
public enum Language {

English, Russian, Czech

}
jsonb.toJson(Language.English); // "English"

Default Mapping - Enumerations
• Serialization: 

name()
• Deserialization: 

valueOf(String)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 4343
// JsonObject
JsonBuilderFactory factory = Json.createBuilderFactory(null);

JsonObject jsonObject = factory.createObjectBuilder()

.add(“name", "Jason")

.add(“city", "Prague")

.build();



jsonb.toJson(jsonObject); // {“name":"Jason","city":"Prague"}
// JsonValue

jsonb.toJson(JsonValue.TRUE); // true
Default Mapping - JSON-P
• Supported types:
• javax.json.JsonArray
• javax.json.JsonStructure
• javax.json.JsonValue
• javax.json.JsonPointer
• javax.json.JsonString
• javax.json.JsonNumber
• Serialization: 

javax.json.JsonWriter
• Deserialization:

javax.json.JsonReader
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Reference Implementation Demo
44
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 4545
Jason’s Plans
• Web: http://159.203.248.103:8080
• Sources: https://github.com/m0mus/jason_plans
• Demonstrates serialization of this class:
public class JasonPlans {

public Date date;
public int id;
public String response;

}
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 4646
Custom Mapping
• Property names
• Property order
• Ignoring properties
• Null handling
• Simple values
• Custom instantiation
• Custom visibility
• Adapters
• Date/Number Formats
• Binary Handling
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 4747
Custom Mapping - Property Names
public class Customer {

public int id;

public String firstName;

}
{

"id": 1, 

"firstName": "Jason"

}
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 4848
Custom Mapping - Property Names
public class Customer {

private int id;

@JsonbProperty("name")
private String firstName;

}
public class Customer {

public int id;

public String firstName;



@JsonbProperty("name")

public String getFirstName() {

return firstName;

}

}
{

"id": 1, 

"name": "Jason"

}
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 4949
Custom Mapping - Property Names
public class Customer {

public int id;

public String firstName;



@JsonbProperty(“getter-name")

String getFirstName() {

return firstName;

}



@JsonbProperty(“setter-name")

void setFirstName(String str) {

this.firstName = str;

}

}
Serialization:
{

"id": 1, 

“getter-name": "Jason"

}
Deserialization:
{

"id": 1, 

“setter-name": "Jason"

}
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 5050
Custom Mapping - Property Naming Strategy
• IDENTITY
• LOWER_CASE_WITH_DASHES
• LOWER_CASE_WITH_UNDERSCORES
• UPPER_CAMEL_CASE
• UPPER_CAMEL_CASE_WITH_SPACES
• CASE_INSENSITIVE
myMixedCaseProperty
my-mixed-case-property
my_mixed_case_property
MyMixedCaseProperty
My Mixed Case Property
myMixedCaseProperty

mYmIxEdCaSePrOpErTy
JsonbConfig().withPropertyNamingStrategy(…)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 5151
Custom Mapping - Property Order Strategy
• Strategies:
• LEXICOGRAPHICAL
• ANY
• REVERSE
• @JsonbPropertyOrder annotation on class
• JsonbConfig().withPropertyOrderStrategy(…)
{ "a": 1, "b": 2, "c": 3 }
{ "b": 2, "a": 1, "c": 3 }
{ "c": 3, "b": 2, "a": 1 }
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 5252
Custom Mapping - Ignoring Properties
public class Customer {

public int id;
public String name;

}
public class Customer {

public int id;
@JsonbTransient

public String name;

}
{

"id": 1, 

"name": "Jason"

}
{

"id": 1 

}
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 5353
Custom Mapping - Null handling
public class Customer {
private int id = 1;
private String name = null;
}
{

"id": 1 

}
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 5454
Custom Mapping - Null handling
public class Customer {
private int id = 1;
private String name = null;
}
public class Customer {
private int id = 1;
@JsonbNillable
private String name = null;

}
{

"id": 1 

}
{

"id": 1,
"name": null

}
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 5555
Custom Mapping - Null handling
public class Customer {
private int id = 1;
private String name = null;
}
public class Customer {
private int id = 1;
@JsonbNillable
private String name = null;

}
@JsonbNillable
public class Customer {
private int id = 1;
private String name = null;

}
{

"id": 1 

}
{

"id": 1,
"name": null

}
{

"id": 1,
"name": null

}
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 5656
Custom Mapping - Simple Value
public class Language {
public int id = 1;
@JsonbValue
public String code = “en";
public String name = "English";
}
”en”
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 5757
Custom Mapping - Simple Value
public class Language {
public int id = 1;
@JsonbValue
public String code = “en";
public String name = "English";
}
public class Customer {
public int id;
public Language lang;
public String name;
}
”en”
{

"id": 1,
"lang": ”en”,
"name": ”Jason”

}
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 5858
Custom Mapping - Custom Instantiation
public class Customer {
public int id;
public String name;
@JsonbCreator

public static Customer getFromDb(int id) {
return CustomerDao.getByPrimaryKey(id);
}
}
public class Order {
public int id;
public Customer customer;
}
{

"id": 1,
"customer": {
"id": 2 }
}
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 5959
Custom Mapping - Custom Visibility
public class Customer {
public int id;
private String name;
}
@JsonbVisibility(MyVisibilityStrategy.class)
public class Customer {
public int id;
private String name;
}
{

"id": 1
}
{

"id": 1,
"name": "Jason"
}
JsonbConfig config = new JsonbConfig()

.withPropertyVisibilityStrategy(new MyVisibilityStrategy());

Jsonb jsonb = JsonbBuilder.create(config);

String json = jsonb.toJson(obj);
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 6060
Custom Mapping - Adapters
public class Customer {
public int id;
public String name;
@JsonbTypeAdapter(MyAdapter.class)
public CustomerData data;
}
{

"id": 1,
"name": "Jason",
"data": {…},
}
JsonbConfig config = new JsonbConfig().withAdapters(new MyAdapter());

Jsonb jsonb = JsonbBuilder.create(config);

String json = jsonb.toJson(obj);
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 6161
Custom Mapping - Date/Number Format
public class FormatTest {
public Date defaultDate;
@JsonbDateFormat("dd.MM.yyyy")

public Date formattedDate;
public BigDecimal defaultNumber;
@JsonbNumberFormat(“#0.00")

public BigDecimal formattedNumber;
}
{
“defaultDate”: “2015-07-26T23:00:00",
“formattedDate”: ”26.07.2015",
“defaultNumber": 1.2,
“formattedNumber": 1.20
}
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 6262
Custom Mapping - Binary Data Encoding
• BYTE (default)
• BASE_64
• BASE_64_URL
JsonbConfig config = new JsonbConfig()

.withBinaryDataStrategy(BinaryDataStrategy.BASE_64);

Jsonb jsonb = JsonbBuilder.create(config);

String json = jsonb.toJson(obj);
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 6363
Custom Mapping - I-JSON
• I-JSON (”Internet JSON”) is a restricted profile of JSON
• JSON-B fully supports I-JSON by default with three exceptions
• Configuration: withStrictIJSONSerializationCompliance
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
What’s Next
64
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 6565
In Progress
• Early Draft 2
• Reference implementation started at http://eclipselink.org
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 6666
TODO
• Mapping subset of documents (JsonPointer)
• Mapping 3rd party objects
• Bi-directional mapping
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 6767
Special Thanks
• Martin Grebac, Martin Vojtek and all the experts
• Kiev Java User Group (Olena Syrota, Oleg Tsal-Tsalko)
• David Delabassee, Reza Rahman, Heather VanCura, John Clingan
• others on users@jsonb-spec.java.net
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 6868
Call to Action!
• Participate!

users@jsonb-spec.java.net
• Contribute! 

http://eclipselink.org
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 6969
Links
• Spec Project: 

https://java.net/projects/jsonb-spec/pages/Home
• JCP Home: 

https://www.jcp.org/en/jsr/detail?id=367
• Reference Implementation: 

http://eclipselink.org
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Q&A
70
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Safe Harbor Statement
The preceding 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.
71
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 72
What’s new in JSR 367 Java API for JSON Binding
What’s new in JSR 367 Java API for JSON Binding

More Related Content

What's hot

Sem tech 2010_integrity_constraints
Sem tech 2010_integrity_constraintsSem tech 2010_integrity_constraints
Sem tech 2010_integrity_constraintsClark & Parsia LLC
 
What's coming in Java EE 8
What's coming in Java EE 8What's coming in Java EE 8
What's coming in Java EE 8David Delabassee
 
Java: Create The Future Keynote
Java: Create The Future KeynoteJava: Create The Future Keynote
Java: Create The Future KeynoteSimon Ritter
 
Configuration with Apache Tamaya
Configuration with Apache TamayaConfiguration with Apache Tamaya
Configuration with Apache TamayaAnatole Tresch
 
Stardog 1.1: An Easier, Smarter, Faster RDF Database
Stardog 1.1: An Easier, Smarter, Faster RDF DatabaseStardog 1.1: An Easier, Smarter, Faster RDF Database
Stardog 1.1: An Easier, Smarter, Faster RDF Databasekendallclark
 
Eclipse JNoSQL: One API to Many NoSQL Databases - BYOL [HOL5998]
Eclipse JNoSQL: One API to Many NoSQL Databases - BYOL [HOL5998]Eclipse JNoSQL: One API to Many NoSQL Databases - BYOL [HOL5998]
Eclipse JNoSQL: One API to Many NoSQL Databases - BYOL [HOL5998]Otávio Santana
 
Visualizing and Analyzing GC Logs with R
Visualizing and Analyzing GC Logs with RVisualizing and Analyzing GC Logs with R
Visualizing and Analyzing GC Logs with RPoonam Bajaj Parhar
 
Jakarta EE Meets NoSQL in the Cloud Age [DEV6109]
Jakarta EE Meets NoSQL in the Cloud Age [DEV6109]Jakarta EE Meets NoSQL in the Cloud Age [DEV6109]
Jakarta EE Meets NoSQL in the Cloud Age [DEV6109]Otávio Santana
 
The Evolution of Java Persistence
The Evolution of Java PersistenceThe Evolution of Java Persistence
The Evolution of Java PersistenceShaun Smith
 
Functional programming with_jdk8-s_ritter
Functional programming with_jdk8-s_ritterFunctional programming with_jdk8-s_ritter
Functional programming with_jdk8-s_ritterSimon Ritter
 
Modularization With Project Jigsaw in JDK 9
Modularization With Project Jigsaw in JDK 9Modularization With Project Jigsaw in JDK 9
Modularization With Project Jigsaw in JDK 9Simon Ritter
 
APEX Office Hours Interactive Grid Deep Dive
APEX Office Hours Interactive Grid Deep DiveAPEX Office Hours Interactive Grid Deep Dive
APEX Office Hours Interactive Grid Deep DiveJohnSnyders
 
What's New in Java 8
What's New in Java 8What's New in Java 8
What's New in Java 8javafxpert
 
Practical RESTful Persistence
Practical RESTful PersistencePractical RESTful Persistence
Practical RESTful PersistenceShaun Smith
 
Future of Java EE with Java SE 8
Future of Java EE with Java SE 8Future of Java EE with Java SE 8
Future of Java EE with Java SE 8Hirofumi Iwasaki
 
Rollin onj Rubyv3
Rollin onj Rubyv3Rollin onj Rubyv3
Rollin onj Rubyv3Oracle
 
Java EE Revisits GoF Design Patterns
Java EE Revisits GoF Design PatternsJava EE Revisits GoF Design Patterns
Java EE Revisits GoF Design PatternsMurat Yener
 
Have You Seen Java EE Lately?
Have You Seen Java EE Lately?Have You Seen Java EE Lately?
Have You Seen Java EE Lately?Reza Rahman
 
What's New in WebLogic 12.1.3 and Beyond
What's New in WebLogic 12.1.3 and BeyondWhat's New in WebLogic 12.1.3 and Beyond
What's New in WebLogic 12.1.3 and BeyondOracle
 

What's hot (20)

Sem tech 2010_integrity_constraints
Sem tech 2010_integrity_constraintsSem tech 2010_integrity_constraints
Sem tech 2010_integrity_constraints
 
What's coming in Java EE 8
What's coming in Java EE 8What's coming in Java EE 8
What's coming in Java EE 8
 
Java: Create The Future Keynote
Java: Create The Future KeynoteJava: Create The Future Keynote
Java: Create The Future Keynote
 
Configuration with Apache Tamaya
Configuration with Apache TamayaConfiguration with Apache Tamaya
Configuration with Apache Tamaya
 
Stardog 1.1: An Easier, Smarter, Faster RDF Database
Stardog 1.1: An Easier, Smarter, Faster RDF DatabaseStardog 1.1: An Easier, Smarter, Faster RDF Database
Stardog 1.1: An Easier, Smarter, Faster RDF Database
 
Eclipse JNoSQL: One API to Many NoSQL Databases - BYOL [HOL5998]
Eclipse JNoSQL: One API to Many NoSQL Databases - BYOL [HOL5998]Eclipse JNoSQL: One API to Many NoSQL Databases - BYOL [HOL5998]
Eclipse JNoSQL: One API to Many NoSQL Databases - BYOL [HOL5998]
 
Visualizing and Analyzing GC Logs with R
Visualizing and Analyzing GC Logs with RVisualizing and Analyzing GC Logs with R
Visualizing and Analyzing GC Logs with R
 
RR2010 Keynote
RR2010 KeynoteRR2010 Keynote
RR2010 Keynote
 
Jakarta EE Meets NoSQL in the Cloud Age [DEV6109]
Jakarta EE Meets NoSQL in the Cloud Age [DEV6109]Jakarta EE Meets NoSQL in the Cloud Age [DEV6109]
Jakarta EE Meets NoSQL in the Cloud Age [DEV6109]
 
The Evolution of Java Persistence
The Evolution of Java PersistenceThe Evolution of Java Persistence
The Evolution of Java Persistence
 
Functional programming with_jdk8-s_ritter
Functional programming with_jdk8-s_ritterFunctional programming with_jdk8-s_ritter
Functional programming with_jdk8-s_ritter
 
Modularization With Project Jigsaw in JDK 9
Modularization With Project Jigsaw in JDK 9Modularization With Project Jigsaw in JDK 9
Modularization With Project Jigsaw in JDK 9
 
APEX Office Hours Interactive Grid Deep Dive
APEX Office Hours Interactive Grid Deep DiveAPEX Office Hours Interactive Grid Deep Dive
APEX Office Hours Interactive Grid Deep Dive
 
What's New in Java 8
What's New in Java 8What's New in Java 8
What's New in Java 8
 
Practical RESTful Persistence
Practical RESTful PersistencePractical RESTful Persistence
Practical RESTful Persistence
 
Future of Java EE with Java SE 8
Future of Java EE with Java SE 8Future of Java EE with Java SE 8
Future of Java EE with Java SE 8
 
Rollin onj Rubyv3
Rollin onj Rubyv3Rollin onj Rubyv3
Rollin onj Rubyv3
 
Java EE Revisits GoF Design Patterns
Java EE Revisits GoF Design PatternsJava EE Revisits GoF Design Patterns
Java EE Revisits GoF Design Patterns
 
Have You Seen Java EE Lately?
Have You Seen Java EE Lately?Have You Seen Java EE Lately?
Have You Seen Java EE Lately?
 
What's New in WebLogic 12.1.3 and Beyond
What's New in WebLogic 12.1.3 and BeyondWhat's New in WebLogic 12.1.3 and Beyond
What's New in WebLogic 12.1.3 and Beyond
 

Viewers also liked

Java EE 8 - What’s new on the Web front
Java EE 8 - What’s new on the Web frontJava EE 8 - What’s new on the Web front
Java EE 8 - What’s new on the Web frontDavid Delabassee
 
Java ee 8 + security overview
Java ee 8 + security overviewJava ee 8 + security overview
Java ee 8 + security overviewRudy De Busscher
 
HTTP/2 Comes to Java - What Servlet 4.0 Means to You
HTTP/2 Comes to Java - What Servlet 4.0 Means to YouHTTP/2 Comes to Java - What Servlet 4.0 Means to You
HTTP/2 Comes to Java - What Servlet 4.0 Means to YouDavid Delabassee
 
Java EE 8: What Servlet 4.0 and HTTP/2 mean to you
Java EE 8: What Servlet 4.0 and HTTP/2 mean to youJava EE 8: What Servlet 4.0 and HTTP/2 mean to you
Java EE 8: What Servlet 4.0 and HTTP/2 mean to youAlex Theedom
 
What is tackled in the Java EE Security API (Java EE 8)
What is tackled in the Java EE Security API (Java EE 8)What is tackled in the Java EE Security API (Java EE 8)
What is tackled in the Java EE Security API (Java EE 8)Rudy De Busscher
 
Finally, EE Security API JSR 375
Finally, EE Security API JSR 375Finally, EE Security API JSR 375
Finally, EE Security API JSR 375Alex Kosowski
 

Viewers also liked (6)

Java EE 8 - What’s new on the Web front
Java EE 8 - What’s new on the Web frontJava EE 8 - What’s new on the Web front
Java EE 8 - What’s new on the Web front
 
Java ee 8 + security overview
Java ee 8 + security overviewJava ee 8 + security overview
Java ee 8 + security overview
 
HTTP/2 Comes to Java - What Servlet 4.0 Means to You
HTTP/2 Comes to Java - What Servlet 4.0 Means to YouHTTP/2 Comes to Java - What Servlet 4.0 Means to You
HTTP/2 Comes to Java - What Servlet 4.0 Means to You
 
Java EE 8: What Servlet 4.0 and HTTP/2 mean to you
Java EE 8: What Servlet 4.0 and HTTP/2 mean to youJava EE 8: What Servlet 4.0 and HTTP/2 mean to you
Java EE 8: What Servlet 4.0 and HTTP/2 mean to you
 
What is tackled in the Java EE Security API (Java EE 8)
What is tackled in the Java EE Security API (Java EE 8)What is tackled in the Java EE Security API (Java EE 8)
What is tackled in the Java EE Security API (Java EE 8)
 
Finally, EE Security API JSR 375
Finally, EE Security API JSR 375Finally, EE Security API JSR 375
Finally, EE Security API JSR 375
 

Similar to What’s new in JSR 367 Java API for JSON Binding

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 updateMartin Grebac
 
What's Coming in Java EE 8
What's Coming in Java EE 8What's Coming in Java EE 8
What's Coming in Java EE 8PT.JUG
 
Java EE 8 Adopt a JSR : JSON-P 1.1 & MVC 1.0
Java EE 8 Adopt a JSR : JSON-P 1.1 & MVC 1.0Java EE 8 Adopt a JSR : JSON-P 1.1 & MVC 1.0
Java EE 8 Adopt a JSR : JSON-P 1.1 & MVC 1.0David Delabassee
 
JavaOne 2017 - JNoSQL: The Definitive Solution for Java and NoSQL Database [C...
JavaOne 2017 - JNoSQL: The Definitive Solution for Java and NoSQL Database [C...JavaOne 2017 - JNoSQL: The Definitive Solution for Java and NoSQL Database [C...
JavaOne 2017 - JNoSQL: The Definitive Solution for Java and NoSQL Database [C...Leonardo De Moura Rocha Lima
 
Java code coverage with JCov. Implementation details and use cases.
Java code coverage with JCov. Implementation details and use cases.Java code coverage with JCov. Implementation details and use cases.
Java code coverage with JCov. Implementation details and use cases.Alexandre (Shura) Iline
 
112815 java ee8_davidd
112815 java ee8_davidd112815 java ee8_davidd
112815 java ee8_daviddTakashi Ito
 
JavaOne2015フィードバック @ 富山合同勉強会
JavaOne2015フィードバック @ 富山合同勉強会JavaOne2015フィードバック @ 富山合同勉強会
JavaOne2015フィードバック @ 富山合同勉強会Takashi Ito
 
20160123 java one2015_feedback @ Osaka
20160123 java one2015_feedback @ Osaka20160123 java one2015_feedback @ Osaka
20160123 java one2015_feedback @ OsakaTakashi Ito
 
Java EE 8 - An instant snapshot
Java EE 8 - An instant snapshot Java EE 8 - An instant snapshot
Java EE 8 - An instant snapshot David Delabassee
 
2015 Java update and roadmap, JUG sevilla
2015  Java update and roadmap, JUG sevilla2015  Java update and roadmap, JUG sevilla
2015 Java update and roadmap, JUG sevillaTrisha Gee
 
JSLT: JSON querying and transformation
JSLT: JSON querying and transformationJSLT: JSON querying and transformation
JSLT: JSON querying and transformationLars Marius Garshol
 
From Java EE to Jakarta EE
From Java EE to Jakarta EEFrom Java EE to Jakarta EE
From Java EE to Jakarta EEDmitry Kornilov
 
JAX-RS 2.0: RESTful Web Services
JAX-RS 2.0: RESTful Web ServicesJAX-RS 2.0: RESTful Web Services
JAX-RS 2.0: RESTful Web ServicesArun Gupta
 
Building microservices with Kotlin
Building microservices with KotlinBuilding microservices with Kotlin
Building microservices with KotlinHaim Yadid
 
What’s new in Java SE, EE, ME, Embedded world & new Strategy
What’s new in Java SE, EE, ME, Embedded world & new StrategyWhat’s new in Java SE, EE, ME, Embedded world & new Strategy
What’s new in Java SE, EE, ME, Embedded world & new StrategyMohamed Taman
 
Interactive Java Support to your tool -- The JShell API and Architecture
Interactive Java Support to your tool -- The JShell API and ArchitectureInteractive Java Support to your tool -- The JShell API and Architecture
Interactive Java Support to your tool -- The JShell API and ArchitectureJavaDayUA
 

Similar to What’s new in JSR 367 Java API for JSON Binding (20)

Introduction to Yasson
Introduction to YassonIntroduction to Yasson
Introduction to Yasson
 
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
 
What's Coming in Java EE 8
What's Coming in Java EE 8What's Coming in Java EE 8
What's Coming in Java EE 8
 
JavaCro'15 - Java EE 8 - An instant snapshot - David Delabassee
JavaCro'15 - Java EE 8 - An instant snapshot - David DelabasseeJavaCro'15 - Java EE 8 - An instant snapshot - David Delabassee
JavaCro'15 - Java EE 8 - An instant snapshot - David Delabassee
 
Java EE 8 Adopt a JSR : JSON-P 1.1 & MVC 1.0
Java EE 8 Adopt a JSR : JSON-P 1.1 & MVC 1.0Java EE 8 Adopt a JSR : JSON-P 1.1 & MVC 1.0
Java EE 8 Adopt a JSR : JSON-P 1.1 & MVC 1.0
 
JavaOne 2017 - JNoSQL: The Definitive Solution for Java and NoSQL Database [C...
JavaOne 2017 - JNoSQL: The Definitive Solution for Java and NoSQL Database [C...JavaOne 2017 - JNoSQL: The Definitive Solution for Java and NoSQL Database [C...
JavaOne 2017 - JNoSQL: The Definitive Solution for Java and NoSQL Database [C...
 
Java code coverage with JCov. Implementation details and use cases.
Java code coverage with JCov. Implementation details and use cases.Java code coverage with JCov. Implementation details and use cases.
Java code coverage with JCov. Implementation details and use cases.
 
112815 java ee8_davidd
112815 java ee8_davidd112815 java ee8_davidd
112815 java ee8_davidd
 
JavaOne2015フィードバック @ 富山合同勉強会
JavaOne2015フィードバック @ 富山合同勉強会JavaOne2015フィードバック @ 富山合同勉強会
JavaOne2015フィードバック @ 富山合同勉強会
 
20160123 java one2015_feedback @ Osaka
20160123 java one2015_feedback @ Osaka20160123 java one2015_feedback @ Osaka
20160123 java one2015_feedback @ Osaka
 
Java EE 8 - An instant snapshot
Java EE 8 - An instant snapshot Java EE 8 - An instant snapshot
Java EE 8 - An instant snapshot
 
2015 Java update and roadmap, JUG sevilla
2015  Java update and roadmap, JUG sevilla2015  Java update and roadmap, JUG sevilla
2015 Java update and roadmap, JUG sevilla
 
JSLT: JSON querying and transformation
JSLT: JSON querying and transformationJSLT: JSON querying and transformation
JSLT: JSON querying and transformation
 
From Java EE to Jakarta EE
From Java EE to Jakarta EEFrom Java EE to Jakarta EE
From Java EE to Jakarta EE
 
JAX-RS 2.0: RESTful Web Services
JAX-RS 2.0: RESTful Web ServicesJAX-RS 2.0: RESTful Web Services
JAX-RS 2.0: RESTful Web Services
 
Building microservices with Kotlin
Building microservices with KotlinBuilding microservices with Kotlin
Building microservices with Kotlin
 
What’s new in Java SE, EE, ME, Embedded world & new Strategy
What’s new in Java SE, EE, ME, Embedded world & new StrategyWhat’s new in Java SE, EE, ME, Embedded world & new Strategy
What’s new in Java SE, EE, ME, Embedded world & new Strategy
 
Interactive Java Support to your tool -- The JShell API and Architecture
Interactive Java Support to your tool -- The JShell API and ArchitectureInteractive Java Support to your tool -- The JShell API and Architecture
Interactive Java Support to your tool -- The JShell API and Architecture
 
Naver_alternative_to_jpa
Naver_alternative_to_jpaNaver_alternative_to_jpa
Naver_alternative_to_jpa
 
Reactive Spring 5
Reactive Spring 5Reactive Spring 5
Reactive Spring 5
 

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.pptxDmitry Kornilov
 
Jakarta EE: Today and Tomorrow
Jakarta EE: Today and TomorrowJakarta EE: Today and Tomorrow
Jakarta EE: Today and TomorrowDmitry Kornilov
 
Building Cloud-Native Applications with Helidon
Building Cloud-Native Applications with HelidonBuilding Cloud-Native Applications with Helidon
Building Cloud-Native Applications with HelidonDmitry Kornilov
 
Nonblocking Database Access in Helidon SE
Nonblocking Database Access in Helidon SENonblocking Database Access in Helidon SE
Nonblocking Database Access in Helidon SEDmitry 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 FutureDmitry 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 HelidonDmitry 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 HelidonDmitry Kornilov
 
Helidon: Java Libraries for Writing Microservices
Helidon: Java Libraries for Writing MicroservicesHelidon: Java Libraries for Writing Microservices
Helidon: Java Libraries for Writing MicroservicesDmitry Kornilov
 
JSON Support in Java EE 8
JSON Support in Java EE 8JSON Support in Java EE 8
JSON Support in Java EE 8Dmitry 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 TamayaDmitry Kornilov
 

More from Dmitry Kornilov (10)

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
 
Helidon: Java Libraries for Writing Microservices
Helidon: Java Libraries for Writing MicroservicesHelidon: Java Libraries for Writing Microservices
Helidon: Java Libraries for Writing Microservices
 
JSON Support in Java EE 8
JSON Support in Java EE 8JSON Support in Java EE 8
JSON Support in Java EE 8
 
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
 

Recently uploaded

A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Intelisync
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 

Recently uploaded (20)

A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 

What’s new in JSR 367 Java API for JSON Binding

  • 1.
  • 2.
  • 3. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. What’s new in JSR 367 Java API for JSON Binding Dmitry Kornilov EclipseLink MOXy & SDO Team Lead Oracle Czech dmitry.kornilov@oracle.com
  • 4. Copyright © 2015, 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. 4
  • 5. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 5 Program Agenda 1. What is JSONB? 2. JSR Status & Progress 3. What is in the spec 4. The Implementation (with demo) 5. What’s next 6. Q&A session
  • 6. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 6 • JSON Binding is a standard • JSON Binding = JSON-B = JSONB = JSR 367 • It’s about converting Java objects to and from JSON documents What is JSON Binding? 6
  • 7. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 7 What is JSON Binding? 7 public class Customer { public int id; public String firstName; public String lastName; …. } Customer e = new Customer(); e.id = 1; e.firstName = “John”; e.lastName = “Doe”; { "id": 1, "firstName" : "John", "lastName" : "Doe", } Java JSON
  • 8. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 88 Usage in Other Frameworks JAX-RS Objects XML JSON JAXB JSON-B 8
  • 9. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | JSR Status & Progress 9
  • 10. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 1010 JSR 367 Status https://www.jcp.org/en/jsr/detail?id=367
  • 11. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 1111 What’s Done in Last Year • Finished experts group formation • Early Draft published • Reference implementation started
  • 12. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 1212 Experts Group
  • 13. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 1313 Early Draft • Created 20 Aug 2015 • Published 19 Sep 2015
  • 14. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 1414 Reference Implementation Started First JSONB marshaller implementation Signed-off-by: Dmitry Kornilov <dmitry.kornilov@oracle.com> Reviewed-by: Martin Grebac, Lukas Jungmann http://git.eclipse.org/c/eclipselink/eclipselink.runtime.git/log/ author Dmitry Kornilov 2015-09-14 09:06:06 (EDT) committer Dmitry Kornilov 2015-09-14 09:06:18 (EDT)
  • 15. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 1515 Participate!
 users@jsonb-spec.java.net
  • 16. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | JSON-B Specification (Early Draft) 16
  • 17. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 1717 Specification Project • Project Home: 
 https://java.net/projects/jsonb-spec/pages/Home • Sources & samples: 
 https://java.net/projects/jsonb-spec/sources/git/show/api • Document (pdf): 
 https://java.net/projects/jsonb-spec/sources/git/content/spec/spec.pdf
  • 18. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 1818 JSON-B Runtime API 1. Create JSONB engine configuration (optional) 2. Create JSONB engine 3. Use it!
  • 19. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 1919 JSON-B Engine Configuration import javax.json.bind.JsonbConfig; // JSON-B engine configuration JsonbConfig config = new JsonbConfig() .withFormatting(…) .withNullValues(…) .withEncoding(…) .withStrictIJSON(…) .withPropertyNamingStrategy(…) .withPropertyOrderStrategy(…) .withPropertyVisibilityStrategy(…)
 .withAdapters() .withBinaryDataStrategy(…); • Configuration is optional • Managed by one class • Builder pattern is used • Passed to JsonbBuilder
  • 20. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 2020 JSON-B Engine • Jsonb class • Created by JsonbBuilder • Ability to choose JSONP provider import javax.json.bind.Jsonb; import javax.json.bind.JsonbBuilder; // Create JSON-B engine Jsonb jsonb = JsonbBuilder.newBuilder()
 .withConfig(…)
 .withProvider(…)
 .build(); // Create with given config Jsonb jsonb = JsonbBuilder.create(config); // Create with default config Jsonb jsonb = JsonbBuilder.create();
  • 21. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. • toJson(…) • fromJson(…) 2121 JSON-B Engine String toJson(Object object); String toJson(Object object, Type runtimeType); void toJson(Object object, Appendable appendable); void toJson(Object object, Type runtimeType, Appendable appendable); void toJson(Object object, OutputStream stream); void toJson(Object object, Type runtimeType, OutputStream stream); <T> T fromJson(String str, Class<T> type); <T> T fromJson(String str, Type runtimeType); <T> T fromJson(Readable readable, Class<T> type); <T> T fromJson(Readable readable, Type runtimeType); <T> T fromJson(InputStream stream, Class<T> type); <T> T fromJson(InputStream stream, Type runtimeType);
  • 22. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 2222 Default Mapping • Basic Types • Specific Types • Dates • Classes • Collections/Arrays • Enumerations • JSON-P import javax.json.bind.Jsonb; import javax.json.bind.JsonbBuilder; // Create with default config Jsonb jsonb = JsonbBuilder.create();
  • 23. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 2323 • 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) • java.lang.Number Default Mapping - Basic Types
  • 24. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 2424 • 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) • java.lang.Number Long longVal = Long.valueOf(1L);
 String json = jsonb.toJson(longVal);
 // Corresponding toString() method is used on serialization
 json.equals(longVal.toString()); // true Default Mapping - Basic Types
  • 25. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 2525 • 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) • java.lang.Number Long longVal = Long.valueOf(1L);
 String json = jsonb.toJson(longVal);
 // Corresponding toString() method is used on serialization
 json.equals(longVal.toString()); // true // Corresponding parseX() method is used on deserialization
 jsonb.fromJson(json, Long.class) .equals(Long.parseLong(json)); // true Default Mapping - Basic Types
  • 26. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 2626 • 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) • java.lang.Number Long longVal = Long.valueOf(1L);
 String json = jsonb.toJson(longVal);
 // Corresponding toString() method is used on serialization
 json.equals(longVal.toString()); // true // Corresponding parseX() method is used on deserialization
 jsonb.fromJson(json, Long.class) .equals(Long.parseLong(json)); // true jsonb.toJson("string"); // “string” jsonb.toJson('uFFFF'); // "uFFFF" jsonb.toJson((byte)1); // 1 jsonb.toJson((short)1); // 1 jsonb.toJson((int)1); // 1 jsonb.toJson(1L); // 1 jsonb.toJson(1.2f); // 1.2 jsonb.toJson(1.2); // 1.2 jsonb.toJson(true); // true jsonb.toJson(null); // null Default Mapping - Basic Types
  • 27. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 2727 Default Mapping - 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
  • 28. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 2828 Default Mapping - 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 BigDecimal bdVal = BigDecimal.valueOf(1.2); String json = jsonb.toJson(bdVal); // 1.2
 // Corresponding toString() method is used on serialization
 json.equals(bdVal.toString()); // true
  • 29. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 2929 Default Mapping - 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 BigDecimal bdVal = BigDecimal.valueOf(1.2); String json = jsonb.toJson(bdVal); // 1.2
 // Corresponding toString() method is used on serialization
 json.equals(bdVal.toString()); // true // Constructor with string argument is used on deserialization
 jsonb.fromJson(json, BigDecimal.class) .equals(new BigDecimal(1.2)); // true
  • 30. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 3030 Default Mapping - 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 BigDecimal bdVal = BigDecimal.valueOf(1.2); String json = jsonb.toJson(bdVal); // 1.2
 // Corresponding toString() method is used on serialization
 json.equals(bdVal.toString()); // true // Constructor with string argument is used on deserialization
 jsonb.fromJson(json, BigDecimal.class) .equals(new BigDecimal(1.2)); // true // OptionalInt jsonb.toJson(OptionalInt.of(1)); // 1 jsonb.toJson(OptionalInt.empty()); // null
  • 31. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 3131 Default Mapping - Dates ISO_DATE ISO_DATE_TIME Java Type Format java.util.Date ISO_DATE_TIME java.util.Calendar ISO_DATE if to time information present, otherwise ISO_DATE_TIME java.util.GregorianCalendar ISO_DATE if to time information present, otherwise ISO_DATE_TIME java.util.TimeZone NormalizedCustomId (see TimeZone javadoc) 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
  • 32. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 3232 // java.util.Date
 SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy");
 Date parsedDate = sdf.parse("25.10.2015");
 jsonb.toJson(parsedDate)); // ”2015-10-25T00:00:00" Default Mapping - Date Samples
  • 33. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 3333 // java.util.Date
 SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy");
 Date parsedDate = sdf.parse("25.10.2015");
 jsonb.toJson(parsedDate)); // ”2015-10-25T00:00:00" // java.util.Calendar
 Calendar dateCalendar = Calendar.getInstance();
 dateCalendar.clear();
 dateCalendar.set(2015, 10, 25); jsonb.toJson(dateCalendar); // ”2015-10-25” Default Mapping - Date Samples
  • 34. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 3434 // java.util.Date
 SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy");
 Date parsedDate = sdf.parse("25.10.2015");
 jsonb.toJson(parsedDate)); // ”2015-10-25T00:00:00" // java.util.Calendar
 Calendar dateCalendar = Calendar.getInstance();
 dateCalendar.clear();
 dateCalendar.set(2015, 10, 25); jsonb.toJson(dateCalendar); // ”2015-10-25” // java.time.Instant
 jsonb.toJson(Instant.parse(“2015-10-25T23:00:00Z")); // ”2015-10-25T23: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" Default Mapping - Date Samples
  • 35. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 3535 Default Mapping - Classes • Public and protected nested and static nested classes • Anonymous classes (serialization only) • Inheritance is supported • Default no-argument constructor is required for deserialization
  • 36. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 3636 Default Mapping - Fields • Final fields are supported (serialization only) • Static fields are not supported • Transient fields are not supported • Null fields are skipped • Lexicographical order • Parent class fields are serialized before child class fields
  • 37. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 3737 Fields Order Sample { 
 "parentA": 1, "parentB": 2 } public class Parent {
 public int parentB;
 public int parentA;
 }
  • 38. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 3838 Fields Order Sample { 
 "parentA": 1, "parentB": 2 } { 
 "parentA": 1, "parentB": 2, "childA": 3, "childB": 4 } public class Parent {
 public int parentB;
 public int parentA;
 } public class Child extends Parent {
 public int childB;
 public int childA;
 }
  • 39. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 3939 Default Mapping - 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
  • 40. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 4040 Scope and Field Access Strategy Sample { 
 "publicFinalField": 1, "publicFieldWithNoGetter": 1, "privateFieldWithPublicGetter": 1, "noField": 1, } public class Foo { public final int publicFinalField; private final int privateFinalField; public static int publicStaticField; 
 public int publicFieldWithNoGetter;
 public int publicFieldWithPrivateGetter; public Integer publicNullField = null; private int privateFieldWithNoGetter; private int privateFieldWithPublicGetter; public int getNoField() {}; public void setNoField(int value) {};
 }
  • 41. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 4141 // Array int[] intArray = {1, 2, 3}; 
 jsonb.toJson(intArray); // [1,2,3] // Collection
 Collection<Object> list = new ArrayList<>();
 list.add(1);
 list.add(2); list.add(null);
 
 jsonb.toJson(list); // [1,2,null] // Map
 Map<String, Object> map = new LinkedHashMap<>();
 map.put("first", 1);
 map.put("second", 2);
 
 jsonb.toJson(map); // {"first":1,"second":2} Default Mapping - 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 • EnumMap
  • 42. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 4242 public enum Language {
 English, Russian, Czech
 } jsonb.toJson(Language.English); // "English"
 Default Mapping - Enumerations • Serialization: 
 name() • Deserialization: 
 valueOf(String)
  • 43. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 4343 // JsonObject JsonBuilderFactory factory = Json.createBuilderFactory(null);
 JsonObject jsonObject = factory.createObjectBuilder()
 .add(“name", "Jason")
 .add(“city", "Prague")
 .build();
 
 jsonb.toJson(jsonObject); // {“name":"Jason","city":"Prague"} // JsonValue
 jsonb.toJson(JsonValue.TRUE); // true Default Mapping - JSON-P • Supported types: • javax.json.JsonArray • javax.json.JsonStructure • javax.json.JsonValue • javax.json.JsonPointer • javax.json.JsonString • javax.json.JsonNumber • Serialization: 
 javax.json.JsonWriter • Deserialization:
 javax.json.JsonReader
  • 44. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Reference Implementation Demo 44
  • 45. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 4545 Jason’s Plans • Web: http://159.203.248.103:8080 • Sources: https://github.com/m0mus/jason_plans • Demonstrates serialization of this class: public class JasonPlans {
 public Date date; public int id; public String response;
 }
  • 46. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 4646 Custom Mapping • Property names • Property order • Ignoring properties • Null handling • Simple values • Custom instantiation • Custom visibility • Adapters • Date/Number Formats • Binary Handling
  • 47. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 4747 Custom Mapping - Property Names public class Customer {
 public int id;
 public String firstName;
 } {
 "id": 1, 
 "firstName": "Jason"
 }
  • 48. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 4848 Custom Mapping - Property Names public class Customer {
 private int id;
 @JsonbProperty("name") private String firstName;
 } public class Customer {
 public int id;
 public String firstName;
 
 @JsonbProperty("name")
 public String getFirstName() {
 return firstName;
 }
 } {
 "id": 1, 
 "name": "Jason"
 }
  • 49. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 4949 Custom Mapping - Property Names public class Customer {
 public int id;
 public String firstName;
 
 @JsonbProperty(“getter-name")
 String getFirstName() {
 return firstName;
 }
 
 @JsonbProperty(“setter-name")
 void setFirstName(String str) {
 this.firstName = str;
 }
 } Serialization: {
 "id": 1, 
 “getter-name": "Jason"
 } Deserialization: {
 "id": 1, 
 “setter-name": "Jason"
 }
  • 50. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 5050 Custom Mapping - Property Naming Strategy • IDENTITY • LOWER_CASE_WITH_DASHES • LOWER_CASE_WITH_UNDERSCORES • UPPER_CAMEL_CASE • UPPER_CAMEL_CASE_WITH_SPACES • CASE_INSENSITIVE myMixedCaseProperty my-mixed-case-property my_mixed_case_property MyMixedCaseProperty My Mixed Case Property myMixedCaseProperty
 mYmIxEdCaSePrOpErTy JsonbConfig().withPropertyNamingStrategy(…)
  • 51. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 5151 Custom Mapping - Property Order Strategy • Strategies: • LEXICOGRAPHICAL • ANY • REVERSE • @JsonbPropertyOrder annotation on class • JsonbConfig().withPropertyOrderStrategy(…) { "a": 1, "b": 2, "c": 3 } { "b": 2, "a": 1, "c": 3 } { "c": 3, "b": 2, "a": 1 }
  • 52. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 5252 Custom Mapping - Ignoring Properties public class Customer {
 public int id; public String name;
 } public class Customer {
 public int id; @JsonbTransient
 public String name;
 } {
 "id": 1, 
 "name": "Jason"
 } {
 "id": 1 
 }
  • 53. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 5353 Custom Mapping - Null handling public class Customer { private int id = 1; private String name = null; } {
 "id": 1 
 }
  • 54. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 5454 Custom Mapping - Null handling public class Customer { private int id = 1; private String name = null; } public class Customer { private int id = 1; @JsonbNillable private String name = null;
 } {
 "id": 1 
 } {
 "id": 1, "name": null
 }
  • 55. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 5555 Custom Mapping - Null handling public class Customer { private int id = 1; private String name = null; } public class Customer { private int id = 1; @JsonbNillable private String name = null;
 } @JsonbNillable public class Customer { private int id = 1; private String name = null;
 } {
 "id": 1 
 } {
 "id": 1, "name": null
 } {
 "id": 1, "name": null
 }
  • 56. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 5656 Custom Mapping - Simple Value public class Language { public int id = 1; @JsonbValue public String code = “en"; public String name = "English"; } ”en”
  • 57. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 5757 Custom Mapping - Simple Value public class Language { public int id = 1; @JsonbValue public String code = “en"; public String name = "English"; } public class Customer { public int id; public Language lang; public String name; } ”en” {
 "id": 1, "lang": ”en”, "name": ”Jason”
 }
  • 58. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 5858 Custom Mapping - Custom Instantiation public class Customer { public int id; public String name; @JsonbCreator
 public static Customer getFromDb(int id) { return CustomerDao.getByPrimaryKey(id); } } public class Order { public int id; public Customer customer; } {
 "id": 1, "customer": { "id": 2 } }
  • 59. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 5959 Custom Mapping - Custom Visibility public class Customer { public int id; private String name; } @JsonbVisibility(MyVisibilityStrategy.class) public class Customer { public int id; private String name; } {
 "id": 1 } {
 "id": 1, "name": "Jason" } JsonbConfig config = new JsonbConfig()
 .withPropertyVisibilityStrategy(new MyVisibilityStrategy());
 Jsonb jsonb = JsonbBuilder.create(config);
 String json = jsonb.toJson(obj);
  • 60. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 6060 Custom Mapping - Adapters public class Customer { public int id; public String name; @JsonbTypeAdapter(MyAdapter.class) public CustomerData data; } {
 "id": 1, "name": "Jason", "data": {…}, } JsonbConfig config = new JsonbConfig().withAdapters(new MyAdapter());
 Jsonb jsonb = JsonbBuilder.create(config);
 String json = jsonb.toJson(obj);
  • 61. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 6161 Custom Mapping - Date/Number Format public class FormatTest { public Date defaultDate; @JsonbDateFormat("dd.MM.yyyy")
 public Date formattedDate; public BigDecimal defaultNumber; @JsonbNumberFormat(“#0.00")
 public BigDecimal formattedNumber; } { “defaultDate”: “2015-07-26T23:00:00", “formattedDate”: ”26.07.2015", “defaultNumber": 1.2, “formattedNumber": 1.20 }
  • 62. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 6262 Custom Mapping - Binary Data Encoding • BYTE (default) • BASE_64 • BASE_64_URL JsonbConfig config = new JsonbConfig()
 .withBinaryDataStrategy(BinaryDataStrategy.BASE_64);
 Jsonb jsonb = JsonbBuilder.create(config);
 String json = jsonb.toJson(obj);
  • 63. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 6363 Custom Mapping - I-JSON • I-JSON (”Internet JSON”) is a restricted profile of JSON • JSON-B fully supports I-JSON by default with three exceptions • Configuration: withStrictIJSONSerializationCompliance
  • 64. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | What’s Next 64
  • 65. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 6565 In Progress • Early Draft 2 • Reference implementation started at http://eclipselink.org
  • 66. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 6666 TODO • Mapping subset of documents (JsonPointer) • Mapping 3rd party objects • Bi-directional mapping
  • 67. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 6767 Special Thanks • Martin Grebac, Martin Vojtek and all the experts • Kiev Java User Group (Olena Syrota, Oleg Tsal-Tsalko) • David Delabassee, Reza Rahman, Heather VanCura, John Clingan • others on users@jsonb-spec.java.net
  • 68. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 6868 Call to Action! • Participate!
 users@jsonb-spec.java.net • Contribute! 
 http://eclipselink.org
  • 69. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. 6969 Links • Spec Project: 
 https://java.net/projects/jsonb-spec/pages/Home • JCP Home: 
 https://www.jcp.org/en/jsr/detail?id=367 • Reference Implementation: 
 http://eclipselink.org
  • 70. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Q&A 70
  • 71. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Safe Harbor Statement The preceding 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. 71
  • 72. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 72