Java Reference
In-Depth Information
<title>Generated JSON with the JSON-P Object Model API</title>
<h:panelGrid columns="2">
<h:outputLabel for="parsedJson" value="Parsed JSON"/>
value="#{jsonPModelApiBean.jsonStr}" rows="4"/>
<h:commandButton value="Submit"
It simply displays a text area that contains the JSON representation of the Person
object, as shown in the following screenshot:
Notice how the property names match the ones we used to create the JSON object
in the previous section, and all the values match the values we entered on the input
page we just discussed. At this point, we can modify the JSON string displayed in
the text area (making sure that it is still properly formatted JSON). When the user
clicks on the Submit button, the Person object will be repopulated from the updated
JSON string.
Parsing JSON data with the JSON-P object
model API
Now that we know how to generate JSON from Java objects, let's focus our attention
on the opposite functionality, populating Java objects from JSON strings.
Search WWH ::

Custom Search