Complete Java Enterprise Edition 8 specification APIs providing all standardized enterprise application development interfaces
—
JSON-P and JSON-B APIs for parsing, generating, and binding JSON data with streaming and object mapping support.
public final class Json {
public static JsonReader createReader(InputStream in);
public static JsonReader createReader(Reader reader);
public static JsonWriter createWriter(OutputStream out);
public static JsonWriter createWriter(Writer writer);
public static JsonObjectBuilder createObjectBuilder();
public static JsonArrayBuilder createArrayBuilder();
public static JsonParser createParser(InputStream in);
public static JsonParser createParser(Reader reader);
public static JsonGenerator createGenerator(OutputStream out);
public static JsonGenerator createGenerator(Writer writer);
}
public interface JsonReader extends Closeable {
JsonStructure read();
JsonObject readObject();
JsonArray readArray();
void close();
}
public interface JsonWriter extends Closeable {
void writeArray(JsonArray array);
void writeObject(JsonObject object);
void write(JsonStructure value);
void close();
}public interface Jsonb extends AutoCloseable {
<T> String toJson(T object);
<T> String toJson(T object, Type runtimeType);
<T> void toJson(T object, OutputStream out);
<T> void toJson(T object, Writer writer);
<T> T fromJson(String str, Class<T> type);
<T> T fromJson(String str, Type runtimeType);
<T> T fromJson(Reader reader, Class<T> type);
<T> T fromJson(Reader reader, Type runtimeType);
<T> T fromJson(InputStream stream, Class<T> type);
<T> T fromJson(InputStream stream, Type runtimeType);
void close() throws Exception;
}
public final class JsonbBuilder {
public static JsonbBuilder create();
public JsonbBuilder withConfig(JsonbConfig config);
public JsonbBuilder withProvider(JsonbProvider provider);
public Jsonb build();
}// JSON-P
JsonObject jsonObject = Json.createObjectBuilder()
.add("name", "John Doe")
.add("age", 30)
.add("active", true)
.build();
// JSON-B
Jsonb jsonb = JsonbBuilder.create();
User user = new User("John", "john@example.com");
String json = jsonb.toJson(user);
User deserializedUser = jsonb.fromJson(json, User.class);Install with Tessl CLI
npx tessl i tessl/maven-javax--javaee-api