ference less important, and the time to transmit the smaller compressed data will show the
same benefit as transferring any other compressed HTTP data.
Like HTML data, programmatic data will greatly benefit from reducing whitespace and
An Overview of Parsing and Marshalling
Given a series of XML or JSON strings, a program must convert those strings into data suit-
able for processing by Java. This is called either marshalling or parsing, depending on the
context and the resulting output. The reverse—producing XML or JSON strings from other
data—is called unmarshalling.
There are four general techniques to handle the data:
A parser goes through the tokens of the input data and calls back methods on an object as
it discovers tokens.
The input data is associated with a parser and the program asks for (or pulls) a series of
tokens from the parser.
The input data is converted to a document-style object that the application can then walk
through as it looks for pieces of data.
The input data is converted to one or more Java objects using a set of predefined classes
that reflect the structure of the data (e.g., there will be a predefined Person class for data
that represents an individual).
These techniques are listed in rough order of slowest to fastest, but again the functional dif-
ferences between them are more important than their performance differences. There isn't a
great deal of functional difference between the first two: either parser is adaptable to most al-