Java Reference
In-Depth Information
As we can see, all it does is display all of the Person object properties via the Unified
Expression Language. The object properties are repopulated from the JSON string
that was displayed on the previous page, which is bound to the jsonStr property
of JsonPModelApiBean .
As we can see, populating and parsing JSON using JSON-P's object model API is
fairly straightforward and intuitive. It works great when we are dealing with smaller
amounts of data. It might be possible, however, to run into performance problems
when dealing with large amounts of data. In such instances, we can use JSON-P's
streaming API.
The JSON-P streaming API
The JSON-P streaming API allows us to read and write JSON data to and from a
stream (a subclass of java.io.OutputStream or a subclass of java.io.Writer ). The
JSON-P streaming API has better performance and better memory efficiency than the
JSON-P object model API. These performance and efficiency gains, however, come
with some limitations. The JSON-P streaming API only allows JSON data to be read
sequentially; we can't access JSON properties directly like we can with the object
model API. In general, we should use the streaming API if we need to handle large
amount of JSON data; otherwise, the simpler object model API should be used.
In the following sections, we will reimplement the example from the previous section
using the JSON-P streaming API.
Since the examples on this section mirror the functionality we
implemented in the previous sections, we will not show any screenshots
of our sample application in action. They will be identical to the ones we
saw earlier on this chapter.
 
Search WWH ::




Custom Search