Skip navigation links

Package org.json.stream

A streaming parser implementation and related tools for JSON.

See: Description

Package org.json.stream Description

A streaming parser implementation and related tools for JSON. Implements a streaming pull parser with the following components:

Stream Reader

JSONStreamReader provides an implementation of a streaming pull-parser, similar to JSR 353 for JavaEE, or the Jackson JSON parser. The stream reader reads strictly conforming JSON data, and has "hooks" to allow reading of long data, such as base64-encoded data within a JSON string.

This reader should be considered when the source JSON data is from a known safe origin.

Object Builder

JSONObjectBuilder is a builder of JSONObject and JSONArray structures built on top of the stream reader. The implementation ends up simpler than JSONTokener, mainly because a lot of the heavy lifting is done in the stream reader.

Limit Stream Reader

JSONLimitStreamReader provides a stream reader that is better at dealing with JSON data from untrusted origins, such as unknown internet connections. It is build with deliberate boundaries that avoid memory exhaustion and other data storage limits, for the purposes of denial-of-service attacks.

Limit Object Builder

JSONLimitBuilder is built on top of the limit stream reader above, it limits its use of the runtime stack to avoid stack smashing attempts from untrusted JSON sources.

This parser may be slower than the other object builder above -- <20% in informal testing -- due to its use of trampolining for creating nested structures.

Builder Limits

BuilderLimits limits that are applied to a limit stream reader and limit object builder. These are based on similar limits found in secure XML processing parsers.

Limit Filter

LimitFilter provides an easy interface for accepting or rejecting particular structures during a JSON parse process.

Structure Collector

StructureCollector parameterizes the type of structures to be created by the object builders. Two provided collectors are:

Skip navigation links