JSON, or the JavaScript Object Notation, is a human-readable data interchange format. As its name implies, JSON is derived from JavaScript. Java EE 7 introduced JSON-P, the Java API for JSON processing. Java EE 8 introduced an additional JSON API, namely, the Java API for JSON Binding (JSON-B). In this chapter, we will cover both JSON-P and JSON-B.
JSON-P includes two APIs for processing JSON, the Model API and the Streaming API, both of which will be covered in this chapter. JSON-B transparently populates Java objects from JSON strings, as well as easily generating JSON strings from Java objects.
In this chapter, we will cover the following topics:
- The JSON-P Model API:
- Generating JSON data with the Model API
- Parsing JSON data with the Model API
- The JSON-P Streaming API:
- Generating JSON data with the Streaming API
- Parsing JSON data with the Streaming API
- Populating Java objects from JSON with JSON-B
- Generating JSON strings from Java objects with JSON-B