December 2017
Intermediate to advanced
372 pages
8h 46m
English
At the heart of the JSON-P Model API is the JsonObjectBuilder class. This class has several overloaded add() methods, which can be used to add properties and their corresponding values to generated JSON data.
The following code sample illustrates how to generate JSON data using the Model API:
package net.ensode.javaee8book.jsonpobject;
//other imports omitted for brevity.
import javax.inject.Named;
import javax.json.Json;
import javax.json.JsonObject;
import javax.json.JsonReader;
import javax.json.JsonWriter;
@Named
@SessionScoped
public class JsonpBean implements Serializable{
private String jsonStr;
@Inject
private Customer customer;
public String buildJson() {
JsonObjectBuilder jsonObjectBuilder ...Read now
Unlock full access