December 2017
Intermediate to advanced
372 pages
8h 46m
English
The JSON Streaming API has a JsonGenerator class that we can use to generate JSON data and write it to a stream. This class has several overloaded write() methods, which can be used to add properties and their corresponding values to the generated JSON data.
The following code sample illustrates how to generate JSON data using the Streaming API:
package net.ensode.javaee8book.jsonpstreaming; //other imports omitted import javax.json.Json; import javax.json.stream.JsonGenerator; import javax.json.stream.JsonParser; import javax.json.stream.JsonParser.Event; @Named @SessionScoped public class JsonpBean implements Serializable { private String jsonStr; @Inject private Customer customer; public String ...Read now
Unlock full access