Quick revision
The short answer
JSON-P (Jakarta JSON Processing, package jakarta.json) is a standard API for parsing and building JSON either as a tree of JsonObject and JsonArray or as a stream of events with JsonParser and JsonGenerator, and it also implements JSON Pointer and JSON Patch. JSON-B (Jakarta JSON Binding, package jakarta.json.bind) is a standard API that maps Java objects to JSON and back, with Yasson as its reference implementation. Jackson is a non-standard library that does both jobs with its own API and is Spring Boot's default, while org.json is a small, older library with JSONObject and JSONArray and no object binding at all.
What to remember
In this answer, we separated JSON processing from JSON binding. JSON-P is the Jakarta standard for processing, with an object model, a streaming parser and generator, and support for JSON Pointer and JSON Patch. JSON-B is the Jakarta standard for binding, with Jsonb.toJson and fromJson, annotations such as @JsonbProperty and Yasson as the reference implementation. Jackson does both jobs with its own non-standard API and is Spring Boot's default, while org.json is a small, older processing library with no binding.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
JSON-P (Jakarta JSON Processing, package jakarta.json) is a standard API for parsing and building JSON either as a tree of JsonObject and JsonArray or as a stream of events with JsonParser and JsonGenerator, and it also implements JSON Pointer and JSON Patch. JSON-B (Jakarta JSON Binding, package jakarta.json.bind) is a standard API that maps Java objects to JSON and back, with Yasson as its reference implementation. Jackson is a non-standard library that does both jobs with its own API and is Spring Boot's default, while org.json is a small, older library with JSONObject and JSONArray and no object binding at all.
Why this question is asked
Java developers meet JSON through many different names, and it is easy to mix them up: some are specifications, some are implementations, and some are simply popular libraries. Knowing which is which matters when we choose a dependency for a shared library, move code between a Jakarta EE server and Spring Boot, or read a stack trace that mentions Yasson. Interviewers ask this to check that we understand the difference between a standard API and a library. In this answer, we will recap the two kinds of JSON work, look at JSON-P with its tree, streaming and patch features, then at JSON-B, and finally place Jackson and org.json next to them, including how Spring Boot uses each.
1Two Kinds of JSON Work
There are two quite different ways to work with JSON in Java. The first is processing: we treat the JSON as generic data, a tree of objects, arrays, strings and numbers, and we walk or build that tree in code. Nothing is tied to our own classes. The second is binding: we have a Java class, such as a record called Order, and we want the library to turn an Order into JSON and JSON back into an Order, matching JSON properties to Java fields or components.
Jakarta EE, the standard set of Java enterprise APIs that used to be Java EE, defines one specification for each kind of work. JSON-P covers processing and JSON-B covers binding. A specification is only an API plus a description of how it must behave; another project supplies the code that actually runs, called the implementation.
| Name | Kind | Main types | Implementation |
|---|---|---|---|
JSON-P (jakarta.json) | standard, processing | JsonObject, JsonArray, JsonParser | Eclipse Parsson |
JSON-B (jakarta.json.bind) | standard, binding | Jsonb, @JsonbProperty | Eclipse Yasson |
| Jackson | library, both | ObjectMapper, JsonNode, JsonParser | itself |
org.json | library, processing only | JSONObject, JSONArray | itself |
2JSON-P: Trees, Streams and Patches
JSON-P has two models. The object model reads the whole document into memory as an immutable tree, which is easy to use for small documents. The streaming model reads the document as a sequence of events, such as START_OBJECT, KEY_NAME and VALUE_STRING, which uses very little memory and suits large files.
Notice the last part. JSON Pointer (RFC 6901) is a tiny path syntax that addresses one value, and JSON Patch (RFC 6902) is a list of operations, such as add, remove and replace, applied to a document. JSON-P also supports JSON Merge Patch (RFC 7396). Having these in a standard API is useful for HTTP PATCH endpoints.
3JSON-B: Mapping Objects to JSON
JSON-B sits on top of processing and gives us binding. We create a Jsonb instance and ask it to convert objects. Annotations adjust the mapping, much as Jackson's annotations do, but with their own names.
JsonbBuilder.create() locates an implementation through the service loader, so the code depends only on the API jar while Yasson does the work. By default, JSON-B sorts properties alphabetically and leaves out nulls, which is why customer comes before order_id; @JsonbPropertyOrder and @JsonbNillable change that. Record support depends on the JSON-B and Yasson versions, so check your version for older runtimes. Because Jsonb holds caches, it should be created once and reused, then closed when the application stops.
4Where Jackson and org.json Fit
Jackson is not a Jakarta standard. It is an independent library that offers both processing (JsonNode trees and its own streaming JsonParser) and binding (ObjectMapper) through its own API and annotations, plus many modules for formats like YAML, CBOR and XML. It became the de facto choice in the Java ecosystem because it is fast, very configurable and well integrated with frameworks. Jackson 3 moved the core classes to the tools.jackson packages, while the annotations kept their old package, so check your version when reading imports.
org.json is much older and much smaller. It gives us JSONObject and JSONArray, which behave like maps and lists, and nothing more: there is no binding to our classes, no streaming API, and a JSONObject does not keep the order of its keys. It is fine for a quick script, but it is rarely the right choice for service code.
5How Spring Boot Uses Them
Spring Boot auto-configures Jackson as the JSON library for Spring MVC, WebFlux, the REST clients and its JSON test slices. If Jackson is missing and a JSON-B implementation is on the classpath, Spring can use a JSON-B message converter instead, and there is a property to prefer JSON-B or Gson when several are present (spring.mvc.converters.preferred-json-mapper in Boot 3; check your version, as Boot 4 reorganised some of these properties). In practice, almost every Spring Boot service uses Jackson, and JSON-B is mostly met in code written for Jakarta EE or MicroProfile runtimes such as Open Liberty or Payara, where the server provides it.
6Follow-up questions
Why would anyone choose JSON-B over Jackson?
Mainly portability inside Jakarta EE. If the code runs on an application server that already provides JSON-B, using the standard API means no extra dependency and no version conflict with the server, and the code moves between servers that implement the same specification. Outside that world, Jackson's features and ecosystem usually win.
Can JSON-P and Jackson be used together?
Yes. Jackson has a module (jackson-datatype-jakarta-jsonp) that teaches ObjectMapper to read and write JSON-P types such as JsonObject and JsonPatch, which is handy when a PATCH endpoint receives a JsonPatch in a Spring application. Check your Jackson version for the exact artifact name.
Is org.json the same as the JSON-P JsonObject?
No. They are different classes from different projects that happen to share a name. org.json.JSONObject is mutable and map-like, while jakarta.json.JsonObject is immutable and built with a builder. Mixing them up in imports is a common source of confusing compile errors.
7Conclusion
In this answer, we separated JSON processing from JSON binding. JSON-P is the Jakarta standard for processing, with an object model, a streaming parser and generator, and support for JSON Pointer and JSON Patch. JSON-B is the Jakarta standard for binding, with Jsonb.toJson and fromJson, annotations such as @JsonbProperty and Yasson as the reference implementation. Jackson does both jobs with its own non-standard API and is Spring Boot's default, while org.json is a small, older processing library with no binding.
Open with
JSON-P and JSON-B are two Jakarta EE specifications. JSON-P, in the jakarta.json package, is about processing JSON as generic data. It has an object model where you build or read an immutable tree of JsonObject and JsonArray, and a streaming model with JsonParser and JsonGenerator that reads or writes events one at a time, which is good for large documents.
Then, if they want more
It also implements JSON Pointer for addressing one value and JSON Patch and Merge Patch for applying changes. JSON-B, in jakarta.json.bind, is about binding: you call Jsonb.toJson on an object and fromJson with a class, and you adjust the mapping with annotations like @JsonbProperty or @JsonbTransient.
Being specifications, they need an implementation: Parsson for JSON-P and Yasson as the reference implementation of JSON-B, and an application server usually supplies them.
Jackson is not a standard; it is an independent library that does both processing and binding with its own ObjectMapper, JsonNode and annotations, and it is what Spring Boot auto-configures by default, although Spring can use a JSON-B converter instead. org.json is a much older and smaller library with JSONObject and JSONArray only, no binding to classes and no key order, so I would keep it out of service code.
In short, I would use JSON-B in Jakarta EE runtimes for portability and Jackson in Spring Boot.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the official documentation for the version you use. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "What are Jakarta JSON Processing (JSON-P) and Jakarta JSON Binding (JSON-B), and how do...": https://scrivio-interview-library.netlify.app/java/json-libraries/7cedf3a5e8/