public final class JSONLimitBuilder
extends java.lang.Object
JSONLimitStreamReader
,
using secure principles derived from XML parsers.
This class is similar in its external contract to the JSONObjectBuilder
class, but intended to be more robust against untrusted JSON sources.
For instance, by not using runtime stack for parsing nested JSON structures,
it is less susceptible to stack smashing attempts.
For some practical limits for parsing JSON data, see BuilderLimits.secureDefaults()
.
Modifier and Type | Method and Description |
---|---|
static JSONArray |
buildArraySubTree(JSONLimitStreamReader reader,
BuilderLimits limits)
If the given
JSONLimitStreamReader 's ParseState was JSONStreamReader.ParseState.ARRAY ,
return the entire subtree as an array type, as specified by the given
collector. |
static <AR> AR |
buildArraySubTree(JSONLimitStreamReader reader,
BuilderLimits limits,
StructureCollector<?,?,?,AR> collector)
If the given
JSONLimitStreamReader 's ParseState was JSONStreamReader.ParseState.ARRAY ,
return the entire subtree as an array type. |
static JSONArray |
buildJSONArray(java.io.InputStream inputStream,
java.nio.charset.Charset charset)
Build a
JSONArray from a InputStream and supplied
Charset . |
static JSONArray |
buildJSONArray(java.io.InputStream inputStream,
java.nio.charset.Charset charset,
BuilderLimits limits)
Build a
JSONArray from a InputStream and supplied
Charset . |
static <AR> AR |
buildJSONArray(java.io.InputStream inputStream,
java.nio.charset.Charset charset,
BuilderLimits limits,
StructureCollector<?,?,?,AR> collector)
Build a JSON array from a
InputStream and supplied
Charset . |
static JSONArray |
buildJSONArray(JSONLimitStreamReader reader)
Build a
JSONArray from a JSONLimitStreamReader . |
static JSONArray |
buildJSONArray(JSONLimitStreamReader reader,
BuilderLimits limits)
Build a
JSONArray from a JSONStreamReader . |
static <AR> AR |
buildJSONArray(JSONLimitStreamReader reader,
BuilderLimits limits,
StructureCollector<?,?,?,AR> collector)
Build a JSON array from a
JSONStreamReader . |
static JSONArray |
buildJSONArray(java.io.Reader reader)
Build a
JSONArray from a Reader . |
static JSONArray |
buildJSONArray(java.io.Reader reader,
BuilderLimits limits)
Build a
JSONArray from a Reader . |
static <AR> AR |
buildJSONArray(java.io.Reader reader,
BuilderLimits limits,
StructureCollector<?,?,?,AR> collector)
Build a JSON array from a
Reader . |
static JSONArray |
buildJSONArray(java.lang.String s)
Build a
JSONArray from a String . |
static JSONArray |
buildJSONArray(java.lang.String s,
BuilderLimits limits)
Build a
JSONArray from a String . |
static <AR> AR |
buildJSONArray(java.lang.String s,
BuilderLimits limits,
StructureCollector<?,?,?,AR> collector)
Build a JSON array from a
String . |
static JSONObject |
buildJSONObject(java.io.InputStream inputStream,
java.nio.charset.Charset charset)
Build a
JSONObject from a InputStream and supplied
Charset . |
static JSONObject |
buildJSONObject(java.io.InputStream inputStream,
java.nio.charset.Charset charset,
BuilderLimits limits)
Build a
JSONObject from a InputStream and supplied
Charset . |
static <OR> OR |
buildJSONObject(java.io.InputStream inputStream,
java.nio.charset.Charset charset,
BuilderLimits limits,
StructureCollector<?,?,OR,?> collector)
Build a JSON object from a
InputStream and supplied
Charset . |
static JSONObject |
buildJSONObject(JSONLimitStreamReader reader)
Build a
JSONObject from a JSONLimitStreamReader . |
static JSONObject |
buildJSONObject(JSONLimitStreamReader reader,
BuilderLimits limits)
Build a
JSONObject from a JSONStreamReader . |
static <OR> OR |
buildJSONObject(JSONLimitStreamReader reader,
BuilderLimits limits,
StructureCollector<?,?,OR,?> collector)
Build a JSON object from a
JSONStreamReader . |
static JSONObject |
buildJSONObject(java.io.Reader reader)
Build a
JSONObject from a Reader . |
static JSONObject |
buildJSONObject(java.io.Reader reader,
BuilderLimits limits)
Build a
JSONObject from a Reader . |
static <OR> OR |
buildJSONObject(java.io.Reader reader,
BuilderLimits limits,
StructureCollector<?,?,OR,?> collector)
Build a JSON object from a
Reader . |
static JSONObject |
buildJSONObject(java.lang.String s)
Build a
JSONObject from a String . |
static JSONObject |
buildJSONObject(java.lang.String s,
BuilderLimits limits)
Build a
JSONObject from a String . |
static <OR> OR |
buildJSONObject(java.lang.String s,
BuilderLimits limits,
StructureCollector<?,?,OR,?> collector)
Build a JSON object from a
String . |
static java.lang.Object |
buildJSONValue(java.io.InputStream inputStream,
java.nio.charset.Charset charset)
Build a JSON value from a
InputStream and supplied
Charset . |
static java.lang.Object |
buildJSONValue(java.io.InputStream inputStream,
java.nio.charset.Charset charset,
BuilderLimits limits)
Build a JSON value from a
InputStream and supplied
Charset . |
static java.lang.Object |
buildJSONValue(java.io.InputStream inputStream,
java.nio.charset.Charset charset,
BuilderLimits limits,
StructureCollector<?,?,?,?> collector)
Build a JSON value from a
InputStream and supplied
Charset . |
static java.lang.Object |
buildJSONValue(JSONLimitStreamReader reader)
Build a JSON value from a
JSONStreamReader . |
static java.lang.Object |
buildJSONValue(JSONLimitStreamReader reader,
BuilderLimits limits)
Build a JSON value from a
JSONStreamReader . |
static java.lang.Object |
buildJSONValue(JSONLimitStreamReader reader,
BuilderLimits limits,
StructureCollector<?,?,?,?> collector)
Build a JSON value from a
JSONStreamReader . |
static java.lang.Object |
buildJSONValue(java.io.Reader reader)
Build a JSON value from a
Reader . |
static java.lang.Object |
buildJSONValue(java.io.Reader reader,
BuilderLimits limits)
Build a JSON value from a
Reader . |
static java.lang.Object |
buildJSONValue(java.io.Reader reader,
BuilderLimits limits,
StructureCollector<?,?,?,?> collector)
Build a JSON value from a
Reader . |
static java.lang.Object |
buildJSONValue(java.lang.String s)
Build a JSON value from a
String . |
static java.lang.Object |
buildJSONValue(java.lang.String s,
BuilderLimits limits)
Build a JSON value from a
String . |
static java.lang.Object |
buildJSONValue(java.lang.String s,
BuilderLimits limits,
StructureCollector<?,?,?,?> collector)
Build a JSON value from a
String . |
static JSONObject |
buildObjectSubTree(JSONLimitStreamReader reader,
BuilderLimits limits)
If the given
JSONLimitStreamReader 's ParseState was JSONStreamReader.ParseState.OBJECT ,
return the entire subtree as a JSONObject value. |
static <OR> OR |
buildObjectSubTree(JSONLimitStreamReader reader,
BuilderLimits limits,
StructureCollector<?,?,OR,?> collector)
If the given
JSONLimitStreamReader 's ParseState was JSONStreamReader.ParseState.OBJECT ,
return the entire subtree as an object type, as specified by the given
collector. |
public static java.lang.Object buildJSONValue(java.io.Reader reader, BuilderLimits limits, StructureCollector<?,?,?,?> collector) throws JSONException
Reader
. The value may be one of:
Boolean.TRUE
or Boolean.FALSE
Double
, Long
, Integer
,
BigDecimal
, or BigInteger
String
reader
- A reader.limits
- the limits imposed on the buildercollector
- collector object for creating JSON structuresJSONException
public static java.lang.Object buildJSONValue(java.io.Reader reader, BuilderLimits limits) throws JSONException
Reader
. The value may be one of:
JSONObject.NULL
Boolean.TRUE
or Boolean.FALSE
Double
, Long
, Integer
,
BigDecimal
, or BigInteger
String
JSONObject
JSONArray
reader
- A reader.limits
- the limits imposed on the builderJSONException
public static java.lang.Object buildJSONValue(java.io.Reader reader) throws JSONException
Reader
. The value may be one of:
JSONObject.NULL
Boolean.TRUE
or Boolean.FALSE
Double
, Long
, Integer
,
BigDecimal
, or BigInteger
String
JSONObject
JSONArray
reader
- A reader.JSONException
public static java.lang.Object buildJSONValue(java.io.InputStream inputStream, java.nio.charset.Charset charset, BuilderLimits limits, StructureCollector<?,?,?,?> collector) throws JSONException
InputStream
and supplied
Charset
. The value may be one of:
Boolean.TRUE
or Boolean.FALSE
Double
, Long
, Integer
,
BigDecimal
, or BigInteger
String
inputStream
- the input stream containing the JSON datacharset
- the character set with which to interpret the
input streamlimits
- the limits imposed on the buildercollector
- collector object for creating JSON structuresJSONException
public static java.lang.Object buildJSONValue(java.io.InputStream inputStream, java.nio.charset.Charset charset, BuilderLimits limits) throws JSONException
InputStream
and supplied
Charset
. The value may be one of:
JSONObject.NULL
Boolean.TRUE
or Boolean.FALSE
Double
, Long
, Integer
,
BigDecimal
, or BigInteger
String
JSONObject
JSONArray
inputStream
- the input stream containing the JSON datacharset
- the character set with which to interpret the
input streamlimits
- the limits imposed on the builderJSONException
public static java.lang.Object buildJSONValue(java.io.InputStream inputStream, java.nio.charset.Charset charset) throws JSONException
InputStream
and supplied
Charset
. The value may be one of:
JSONObject.NULL
Boolean.TRUE
or Boolean.FALSE
Double
, Long
, Integer
,
BigDecimal
, or BigInteger
String
JSONObject
JSONArray
inputStream
- the input stream containing the JSON datacharset
- the character set with which to interpret the
input streamJSONException
public static java.lang.Object buildJSONValue(java.lang.String s, BuilderLimits limits, StructureCollector<?,?,?,?> collector) throws JSONException
String
. The value may be one of:
Boolean.TRUE
or Boolean.FALSE
Double
, Long
, Integer
,
BigDecimal
, or BigInteger
String
s
- A source string.limits
- the limits imposed on the buildercollector
- collector object for creating JSON structuresJSONException
public static java.lang.Object buildJSONValue(java.lang.String s, BuilderLimits limits) throws JSONException
String
. The value may be one of:
JSONObject.NULL
Boolean.TRUE
or Boolean.FALSE
Double
, Long
, Integer
,
BigDecimal
, or BigInteger
String
JSONObject
JSONArray
s
- A source string.limits
- the limits imposed on the builderJSONException
public static java.lang.Object buildJSONValue(java.lang.String s) throws JSONException
String
. The value may be one of:
JSONObject.NULL
Boolean.TRUE
or Boolean.FALSE
Double
, Long
, Integer
,
BigDecimal
, or BigInteger
String
JSONObject
JSONArray
s
- A source string.JSONException
public static java.lang.Object buildJSONValue(JSONLimitStreamReader reader) throws JSONException
JSONStreamReader
. The value may be one
of:
JSONObject.NULL
Boolean.TRUE
or Boolean.FALSE
Double
, Long
, Integer
,
BigDecimal
, or BigInteger
String
JSONObject
JSONArray
The reader must be at the beginning of the document.
reader
- A source stream.JSONException
public static java.lang.Object buildJSONValue(JSONLimitStreamReader reader, BuilderLimits limits) throws JSONException
JSONStreamReader
. The value may be one
of:
JSONObject.NULL
Boolean.TRUE
or Boolean.FALSE
Double
, Long
, Integer
,
BigDecimal
, or BigInteger
String
JSONObject
JSONArray
The reader must be at the beginning of the document.
reader
- A source stream.limits
- the limits imposed on the builderJSONException
public static java.lang.Object buildJSONValue(JSONLimitStreamReader reader, BuilderLimits limits, StructureCollector<?,?,?,?> collector) throws JSONException
JSONStreamReader
. The value may be one
of:
Boolean.TRUE
or Boolean.FALSE
Double
, Long
, Integer
,
BigDecimal
, or BigInteger
String
The reader must be at the beginning of the document.
reader
- A source stream.limits
- the limits imposed on the buildercollector
- collector object for creating JSON structuresJSONException
public static <OR> OR buildJSONObject(java.io.Reader reader, BuilderLimits limits, StructureCollector<?,?,OR,?> collector) throws JSONException
Reader
.OR
- the result type of the JSON object constructed by the collectorreader
- A reader.limits
- the limits imposed on the buildercollector
- collector object for creating JSON structuresJSONException
public static JSONObject buildJSONObject(java.io.Reader reader, BuilderLimits limits) throws JSONException
JSONObject
from a Reader
.reader
- A reader.limits
- the limits imposed on the builderJSONObject
valueJSONException
public static JSONObject buildJSONObject(java.io.Reader reader) throws JSONException
JSONObject
from a Reader
.reader
- A reader.JSONObject
valueJSONException
public static <OR> OR buildJSONObject(java.io.InputStream inputStream, java.nio.charset.Charset charset, BuilderLimits limits, StructureCollector<?,?,OR,?> collector) throws JSONException
InputStream
and supplied
Charset
.OR
- the result type of the JSON object constructed by the collectorinputStream
- the input stream containing the JSON datacharset
- the character set with which to interpret the
input streamlimits
- the limits imposed on the buildercollector
- collector object for creating JSON structuresJSONException
public static JSONObject buildJSONObject(java.io.InputStream inputStream, java.nio.charset.Charset charset, BuilderLimits limits) throws JSONException
JSONObject
from a InputStream
and supplied
Charset
.inputStream
- the input stream containing the JSON datacharset
- the character set with which to interpret the
input streamlimits
- the limits imposed on the builderJSONObject
valueJSONException
public static JSONObject buildJSONObject(java.io.InputStream inputStream, java.nio.charset.Charset charset) throws JSONException
JSONObject
from a InputStream
and supplied
Charset
.inputStream
- the input stream containing the JSON datacharset
- the character set with which to interpret the
input streamJSONObject
valueJSONException
public static <OR> OR buildJSONObject(java.lang.String s, BuilderLimits limits, StructureCollector<?,?,OR,?> collector) throws JSONException
String
.OR
- the result type of the JSON object constructed by the collectors
- A source string.limits
- the limits imposed on the buildercollector
- collector object for creating JSON structuresJSONException
public static JSONObject buildJSONObject(java.lang.String s, BuilderLimits limits) throws JSONException
JSONObject
from a String
.s
- A source string.limits
- the limits imposed on the builderJSONObject
valueJSONException
public static JSONObject buildJSONObject(java.lang.String s) throws JSONException
JSONObject
from a String
.s
- A source string.JSONObject
valueJSONException
public static JSONObject buildJSONObject(JSONLimitStreamReader reader) throws JSONException
JSONObject
from a JSONLimitStreamReader
.reader
- A source stream.JSONObject
valueJSONException
public static JSONObject buildJSONObject(JSONLimitStreamReader reader, BuilderLimits limits) throws JSONException
JSONObject
from a JSONStreamReader
. The reader
must be at the beginning of the document.reader
- A source stream.limits
- the limits imposed on the builderJSONObject
valueJSONException
public static <OR> OR buildJSONObject(JSONLimitStreamReader reader, BuilderLimits limits, StructureCollector<?,?,OR,?> collector) throws JSONException
JSONStreamReader
. The reader must be
at the beginning of the document.OR
- the result type of the JSON object constructed by the collectorreader
- A source stream.limits
- the limits imposed on the buildercollector
- collector for creating JSON structuresJSONException
public static <AR> AR buildJSONArray(java.io.Reader reader, BuilderLimits limits, StructureCollector<?,?,?,AR> collector) throws JSONException
Reader
.AR
- the result type of the JSON array constructed by the collectorreader
- A reader.limits
- the limits imposed on the buildercollector
- collector object for creating JSON structuresJSONException
public static JSONArray buildJSONArray(java.io.Reader reader, BuilderLimits limits) throws JSONException
JSONArray
from a Reader
.reader
- A reader.limits
- the limits imposed on the builderJSONArray
valueJSONException
public static JSONArray buildJSONArray(java.io.Reader reader) throws JSONException
JSONArray
from a Reader
.reader
- A reader.JSONArray
valueJSONException
public static <AR> AR buildJSONArray(java.io.InputStream inputStream, java.nio.charset.Charset charset, BuilderLimits limits, StructureCollector<?,?,?,AR> collector) throws JSONException
InputStream
and supplied
Charset
.AR
- the result type of the JSON array constructed by the collectorinputStream
- the input stream containing the JSON datacharset
- the character set with which to interpret the
input streamlimits
- the limits imposed on the buildercollector
- collector object for creating JSON structuresJSONException
public static JSONArray buildJSONArray(java.io.InputStream inputStream, java.nio.charset.Charset charset, BuilderLimits limits) throws JSONException
JSONArray
from a InputStream
and supplied
Charset
.inputStream
- the input stream containing the JSON datacharset
- the character set with which to interpret the
input streamlimits
- the limits imposed on the builderJSONArray
valueJSONException
public static JSONArray buildJSONArray(java.io.InputStream inputStream, java.nio.charset.Charset charset) throws JSONException
JSONArray
from a InputStream
and supplied
Charset
.inputStream
- the input stream containing the JSON datacharset
- the character set with which to interpret the
input streamJSONArray
valueJSONException
public static <AR> AR buildJSONArray(java.lang.String s, BuilderLimits limits, StructureCollector<?,?,?,AR> collector) throws JSONException
String
.AR
- the result type of the JSON array constructed by the collectors
- A source string.limits
- the limits imposed on the buildercollector
- collector object for creating JSON structuresJSONException
public static JSONArray buildJSONArray(java.lang.String s, BuilderLimits limits) throws JSONException
JSONArray
from a String
.s
- A source string.limits
- the limits imposed on the builderJSONArray
valueJSONException
public static JSONArray buildJSONArray(java.lang.String s) throws JSONException
JSONArray
from a String
.s
- A source string.JSONArray
valueJSONException
public static JSONArray buildJSONArray(JSONLimitStreamReader reader) throws JSONException
JSONArray
from a JSONLimitStreamReader
.reader
- A source reader.JSONArray
valueJSONException
public static JSONArray buildJSONArray(JSONLimitStreamReader reader, BuilderLimits limits) throws JSONException
JSONArray
from a JSONStreamReader
. The reader must be
at the beginning of the document.reader
- A source stream.limits
- the limits imposed on the builderJSONArray
valueJSONException
public static <AR> AR buildJSONArray(JSONLimitStreamReader reader, BuilderLimits limits, StructureCollector<?,?,?,AR> collector) throws JSONException
JSONStreamReader
. The reader must be
at the beginning of the document.AR
- the result type of the JSON array constructed by the collectorreader
- A source stream.limits
- the limits imposed on the buildercollector
- collector object for creating structuresJSONException
public static JSONObject buildObjectSubTree(JSONLimitStreamReader reader, BuilderLimits limits) throws JSONException
JSONLimitStreamReader
's ParseState
was JSONStreamReader.ParseState.OBJECT
,
return the entire subtree as a JSONObject value. This method advances the
parser onto the JSONStreamReader.ParseState.END_OBJECT
state.
If the JSON stream is not parseable as an object, a JSONException
will be thrown.
reader
- A source stream reader.limits
- the limits imposed on the builderJSONException
public static <OR> OR buildObjectSubTree(JSONLimitStreamReader reader, BuilderLimits limits, StructureCollector<?,?,OR,?> collector) throws JSONException
JSONLimitStreamReader
's ParseState
was JSONStreamReader.ParseState.OBJECT
,
return the entire subtree as an object type, as specified by the given
collector. This method advances the parser onto the
JSONStreamReader.ParseState.END_OBJECT
state.
If the JSON stream is not parseable as an object, a JSONException
will be thrown.
OR
- the result type of the JSON object constructed by the collectorreader
- A source stream reader.limits
- the limits imposed on the buildercollector
- collector object for creating JSON structuresJSONException
public static JSONArray buildArraySubTree(JSONLimitStreamReader reader, BuilderLimits limits) throws JSONException
JSONLimitStreamReader
's ParseState
was JSONStreamReader.ParseState.ARRAY
,
return the entire subtree as an array type, as specified by the given
collector. This method advances the parser onto the
JSONStreamReader.ParseState.END_ARRAY
state.
If the JSON stream is not parseable as an array, a JSONException
will be thrown.
reader
- A source stream reader.limits
- the limits imposed on the builderJSONArray
representing the subtree starting at the current
ARRAY stateJSONException
public static <AR> AR buildArraySubTree(JSONLimitStreamReader reader, BuilderLimits limits, StructureCollector<?,?,?,AR> collector) throws JSONException
JSONLimitStreamReader
's ParseState
was JSONStreamReader.ParseState.ARRAY
,
return the entire subtree as an array type. This method advances the
parser onto the JSONStreamReader.ParseState.END_ARRAY
state.
If the JSON stream is not parseable as an array, a JSONException
will be thrown.
AR
- the result type of the JSON array constructed by the collectorreader
- A source stream reader.limits
- the limits imposed on the buildercollector
- collector object for creating JSON structuresJSONException