Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

JSON-B is Jakarta’s standard Java API for converting Java objects to JSON and JSON back to Java objects. It supplies sensible default mappings for common cases and standard ways to customize them; to use it in an application, you also need a compatible implementation.

What JSON-B does

JSON-B, short for Jakarta JSON Binding, defines how Java objects and JSON documents are mapped. Its runtime entry point is Jsonb: call toJson to serialize an object as JSON, or fromJson to deserialize JSON into a Java type. The API is designed to handle ordinary property mappings without requiring you to describe every field’s JSON representation yourself.

JSON-B is a specification and API contract, not a complete implementation by itself. Code written against the standard API can use a compatible provider, while provider-specific features may reduce portability.

How to convert Java objects to JSON

Add the JSON-B API and a compatible implementation to the application’s dependencies, then create a Jsonb instance and call its binding methods. Jakarta EE applications may obtain the implementation from their runtime; standalone applications need to ensure a provider is available.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
import jakarta.json.bind.Jsonb;
import jakarta.json.bind.JsonbBuilder;

Jsonb jsonb = JsonbBuilder.create();

String json = jsonb.toJson(myObject);
MyType restored = jsonb.fromJson(json, MyType.class);

The example assumes MyType and myObject are defined in the application, and that the JSON-B API and an implementation are on the runtime classpath or module path. The Jakarta EE tutorial demonstrates instance creation, default mapping, and customization: Jakarta EE Tutorial: JSON Binding.

Defaults and customization

Default mapping is useful when Java property names and types can map naturally to JSON. When the defaults do not match an external JSON contract, JSON-B offers standard extension points:

  • Annotations customize mapping on Java classes and properties.
  • Adapters convert between an application type and a type JSON-B can bind.
  • Serializers and deserializers provide custom conversion behavior for types that need more control.
  • Configuration adjusts binding behavior for a JSON-B instance.

The API reference documents the jakarta.json.bind module and its binding, annotation, adapter, configuration, serializer, and service-provider packages: JSON-B API 3.0.1 API reference.

API and implementation versions

Keep the specification/API version distinct from the implementation version when selecting dependencies. The Jakarta release record identifies JSON-B 3.0 as a Jakarta EE 10 release, requires Java SE 11 or later, and lists Eclipse Yasson 3.0.0 as a compatible implementation. The same record lists API artifact versions through 3.0.2; an API artifact version does not, by itself, indicate a newer specification release.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Check your application server’s supported Jakarta EE level before adding dependencies, so you do not introduce a conflicting API or provider. For a standalone application, include both the API and a provider compatible with the chosen API version. See the JSON-B 3.0 release record for the release’s compatibility details.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What JSON-B guarantees—and what it does not

The specification targets JSON documents compatible with RFC 7159. Serialized output must conform to JSON grammar and use UTF-8. Its listed supported types include basic Java types and standard types such as BigInteger, BigDecimal, URL, URI, and variants of Optional. Consult the Jakarta JSON Binding Specification 3.0 for normative behavior and type details.

Do not rely on a deserialize-then-serialize cycle to reproduce the original JSON text exactly: round-trip equivalence is recommended, not required. JSON Schema generation and validation are outside JSON-B’s specified goals, so applications that need those capabilities must use another tool or library.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.