JSON Binding
Java EE includes support for JSR 367, which provides an API that can serialize Java objects to JSON documents and deserialize JSON documents to Java objects. The Java API for JSON Binding contains the following packages:
-
The
javax.json.bindpackage contains the binding interface, the builder interface, and a configuration class. Table 21-1 lists the main classes and interfaces in this package. -
The
javax.json.bind.adapterpackage contains theJsonbAdapterinterface, which provides methods for binding custom Java types by converting them to known types. -
The
javax.json.bind.annotationpackage defines annotations that can be used to customize default binding behavior. Annotations can be used for field, JavaBean property, type, or package elements. -
The
javax.json.bind.configpackage interfaces and classes for customizing default binding behavior. Table 21-2 lists the main classes and interfaces in this package. -
The
javax.json.bind.serializerpackage contains interfaces that are used to create serialization and deserialization routines for custom types that cannot be easily mapped using theJsonbAdaptermethods. Table 21-3 lists the main interfaces in this package. -
The
javax.json.bind.spipackage contains a Service Provider Interface (SPI) for creating JSON Binding implementations. This package contains theJsonbProviderclass, which contains the methods that a service provider implements.
Table 21-1 Main Classes and Interfaces in javax.json.bind
Class or Interface |
Description |
|
Contains the JSON-B methods for serializing Java objects to JSON and deserailizing JSON to Java objects. |
|
Used by clients to create |
|
Used to set configuration properties on |
|
Indicates that a problem occurred during JSON binding. |
Table 21-2 Main Classes and Interfaces in javax.json.bind.config
Class or Interface |
Description |
|
Used to set how property names are translated. |
|
Used to set whether fields and methods should be considered properties overriding the default scope and field access behavior. |
|
Used to set binary encoding. |
|
Used to set how properties are ordered during serialization. |
Table 21-3 Main Classes and Interfaces in javax.json.bind.serializer
Class or Interface |
Description |
|
Used to create a deserialization routine for a custom type. |
|
Used to create a serialization routine for a custom type. |