CARVIEW |
Select Language
HTTP/2 301
server: GitHub.com
content-type: text/html
location: https://javaee.github.io/jsonb-spec/
x-github-request-id: DC54:262175:AE445:CB768:6880D745
accept-ranges: bytes
age: 0
date: Wed, 23 Jul 2025 12:36:24 GMT
via: 1.1 varnish
x-served-by: cache-bom-vanm7210076-BOM
x-cache: MISS
x-cache-hits: 0
x-timer: S1753274184.488817,VS0,VE212
vary: Accept-Encoding
x-fastly-request-id: 2490734b93f3509ed6454ccb00310618719cc813
content-length: 162
HTTP/2 200
server: GitHub.com
content-type: text/html; charset=utf-8
last-modified: Fri, 15 Feb 2019 11:06:16 GMT
access-control-allow-origin: *
strict-transport-security: max-age=31556952
etag: W/"5c669d28-2d68"
expires: Wed, 23 Jul 2025 12:46:24 GMT
cache-control: max-age=600
content-encoding: gzip
x-proxy-cache: MISS
x-github-request-id: 5B7A:3950E4:ABE52:C90BF:6880D746
accept-ranges: bytes
age: 0
date: Wed, 23 Jul 2025 12:36:24 GMT
via: 1.1 varnish
x-served-by: cache-bom-vanm7210076-BOM
x-cache: MISS
x-cache-hits: 0
x-timer: S1753274185.713375,VS0,VE224
vary: Accept-Encoding
x-fastly-request-id: bba6eaa4ebc2f820af3da7f5e80d302253c10c2c
content-length: 3247
JSON Binding (JSON-B) - Home
What is JSON-B?
JSON-B is a standard binding layer for converting Java objects to/from JSON messages. It defines a default mapping algorithm for converting existing Java classes to JSON, while enabling developers to customize the mapping process through the use of Java annotations.
Consistent
Consistent with JAXB (Java API for XML Binding) and other Java EE and SE APIs where appropriate
Conventional
Define default mapping of Java classes and instances to JSON document counterparts
Customizable
Allow customization of the default mapping definition
Easy to Use
Default use of the APIs should not require prior knowledge of the JSON document format and specification
To serialize/deserialize a Java Object to/from JSON
The Java Class
public class Dog {
public String name;
public int age;
public boolean bitable;
}
JSON-B API calls
public static void main(String[] args) {
// Create a dog instance
Dog dog = new Main.Dog();
dog.name = "Falco";
dog.age = 4;
dog.bitable = false;
// Create Jsonb and serialize
Jsonb jsonb = JsonbBuilder.create();
String result = jsonb.toJson(dog);
System.out.println(result);
// Deserialize back
dog = jsonb.fromJson("{\"name\":\"Falco\",\"age\":4,\"bitable\":false}", Dog.class);
}
The JSON representation
{
"name": "Falco",
"age": 4,
"bitable": false
}
Copyright © 2016-2017 Oracle Corporation. All Rights Reserved.