Jakarta JSON Processing provides portable APIs to parse, generate, transform, and query JSON using the streaming API or the object model API.

The Streaming API provides a way to parsing and generation of JSON in a streaming fashion. It hands over parsing and generation control to the programmer. The streaming API provides an event-based parser and allows an application developer to ask for the next event rather than handling the event in a callback. This gives a developer more procedural control over the processing of the JSON. Application code can process or discard the parser event, and ask for the next event(pull the event). The streaming model is adequate for local processing where random access of other parts of the data is not required. Similarly, the streaming API provides a way to generate well-formed JSON to a stream by writing one event at a time.

The object model API creates a random access tree-like structure that represents the JSON data in memory. The tree can then be navigated and queried. This programming model is the most flexible and enables processing that requires random access to the complete contents of the tree. However, it is often not as efficient as the streaming model and requires more memory. The object model generates JSON output by navigating the entire tree at once.

## The Streaming API

The streaming API is similar to the StAX API for XML and consists of the interfaces {@link javax.json.stream.JsonParser} and {@link javax.json.stream.JsonGenerator}. {@code JsonParser} contains methods to parse JSON data using the streaming model. {@code JsonGenerator} contains methods to write JSON data to an ouptut source.

{@code JsonParser} provides forward, read-only access to JSON data using the pull parsing programming model. In this model the application code controls the thread and calls methods in the parser interface to move the parser forward or to obtain JSON data from the current state of the parser. Refer to this example for more details.

{@code JsonGenerator} provides methods to write JSON to a stream. The generator writes name/value pairs in JSON objects and values in JSON arrays. Refer to this example for more details.

The streaming API is a low-level API designed to process large amounts of JSON data efficiently. Other JSON frameworks (such as JSON binding) can be implemented using this API.

## The Object Model API

The object model API is similar to the DOM API for XML. It is a high-level API that provides immutable object models for JSON object and array structures. These JSON structures are represented as object models using the Java types {@link javax.json.JsonObject} and {@link javax.json.JsonArray}. {@code JsonObject} provides a {@link java.util.Map} view to access the unordered collection of zero or more name/value pairs from the model. Similarly, {@code JsonArray} provides a {@link java.util.List} view to access the ordered sequence of zero or more values from the model.

The object model API uses builder patterns to create these object models. Application code can use the interface {@link javax.json.JsonObjectBuilder} to create models that represent JSON objects. The resulting model is of type {@code JsonObject}. Refer to this example for more details. Application code can use the interface {@link javax.json.JsonArrayBuilder} to create models that represent JSON arrays. The resulting model is of type {@code JsonArray}. Refer to this example for more details.

These object models can also be created from an input source (such as {@link java.io.InputStream} or {@link java.io.Reader}) using the interface {@link javax.json.JsonReader}. This example shows how to read and create an empty {@code JsonArray} model using the interface {@code JsonReader}. Similarly, these object models can be written to an output source (such as {@link java.io.OutputStream} or {@link java.io.Writer}) using the class {@link javax.json.JsonWriter}. This example shows how to write an empty {@code JsonObject} model using the interface {@code JsonWriter}.

## JSON Pointer, JSON Patch, and JSON Merge Patch

Jakarta JSON Processing supports the latest standard on JSON Pointer, JSON Patch, and JSON Merge Patch.