Java Reference
In-Depth Information
See also
F Accessing remote data with HttpRequest
F Downloading images with HttpRequest
F Posting data to remote servers with HttpRequest
F Posting data to servers with HttpRequest
Building RESTful clients with the PullParser
API
Two of the more pervasive formats for information interchange in today's web-enabled
environments are XML and (more recently) JSON (originally stood for JavaScript-Object-
Notation, but has evolved into a general structured data format). These formats have
seen nothing but growing adoptions with the explosion of the programmable web movement.
Companies with content-driven services expose their offerings as platforms to clients of
any types (web-based, desktop, mobile, and so on) to tap into the vast sea of data and
services programmatically.
In this recipe, we will see how you can use JavaFX to process XML and JSON data from remote
servers. To illustrate these capabilities, we will extend the example presented in the previous
recipe Downloading images with HttpRequest , to create a REST-style real estate price
estimator mashup application which uses services from both Google Map and the Zillow Real
Estate engine ( http://www.zillow.com ).
Getting ready
To understand some of the concepts presented here, you should be familiar with the
HttpRequest class. If not, review the recipe Accessing remote data with HttpRequest
to learn how to request data from web servers. For this recipe, we are going to make web
requests from both the Google Map API and the Zillow API to create the real estate price
estimator mashup. You will also need to be familiar with the mechanics of downloading
images from web servers using JavaFX. If you need to some help, see recipe Downloading
images with HttpRequest .
To process XML or JSON payloads, JavaFX provides the PullParser API, located in the javafx.
data.pull package. The PullParser is a fast, event-driven parser that lets developers quickly
parse document nodes as they are encountered during document download. JavaFX provides
a parser for XML and one for JSON. Both parsers use a common API to make it easy to learn
and use.
 
Search WWH ::




Custom Search