CARVIEW |
Select Language
HTTP/2 301
server: GitHub.com
content-type: text/html
location: https://javaee.github.io/jsonb-spec/
x-github-request-id: 6F37:4435A:8DF2:A112:68825071
accept-ranges: bytes
age: 0
date: Thu, 24 Jul 2025 15:25:38 GMT
via: 1.1 varnish
x-served-by: cache-bom-vanm7210036-BOM
x-cache: MISS
x-cache-hits: 0
x-timer: S1753370738.080840,VS0,VE205
vary: Accept-Encoding
x-fastly-request-id: 46f8284c7d0cc4196a15298620a79d7df75f32e5
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: Thu, 24 Jul 2025 15:35:38 GMT
cache-control: max-age=600
content-encoding: gzip
x-proxy-cache: MISS
x-github-request-id: 8F98:EB57F:8DC9:A114:68825071
accept-ranges: bytes
age: 0
date: Thu, 24 Jul 2025 15:25:38 GMT
via: 1.1 varnish
x-served-by: cache-bom-vanm7210036-BOM
x-cache: MISS
x-cache-hits: 0
x-timer: S1753370738.299115,VS0,VE298
vary: Accept-Encoding
x-fastly-request-id: 89051f98dbb89b954a884a4809dfcc02a0e40470
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.