public enum JsonParserTopLevelStrategy extends Enum<JsonParserTopLevelStrategy>
JsonParser strategies of treating of top-level JSON objects in the input and throwing
ParseExceptions.| Enum Constant and Description |
|---|
ALLOW_JUST_A_SINGLE_OBJECT
Bytes input must end exactly on the single JSON object end,
otherwise ParseException is thrown. |
ALLOW_MULTIPLE_VALUES
Allow multiple values to be parsed by a single
JsonParser between
JsonParser.reset() calls and since JsonParser construction. |
ALLOW_TRAILING_GARBAGE
After parsing a single top-level JSON object
JsonParser.parse(net.openhft.lang.io.Bytes) returns true and the (last)
input Bytes might have some remaining
bytes. |
| Modifier and Type | Method and Description |
|---|---|
static JsonParserTopLevelStrategy |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static JsonParserTopLevelStrategy[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final JsonParserTopLevelStrategy ALLOW_JUST_A_SINGLE_OBJECT
Bytes input must end exactly on the single JSON object end,
otherwise ParseException is thrown. Even trailing whitespaces are disallowed
(the contests of the remaining input are not checked indeed).
This strategy is default.
JsonParserBuilder.topLevelStrategy()public static final JsonParserTopLevelStrategy ALLOW_TRAILING_GARBAGE
JsonParser.parse(net.openhft.lang.io.Bytes) returns true and the (last)
input Bytes might have some remaining
bytes.
This option is useful when you are parsing multiple JSON objects from the stream (see
ALLOW_MULTIPLE_VALUES), but need to do some
per-top-level-object work.
public static final JsonParserTopLevelStrategy ALLOW_MULTIPLE_VALUES
JsonParser between
JsonParser.reset() calls and since JsonParser construction. The entire text
must be valid JSON, and values can be separated by any kind of whitespace.
Example of the valid input for a parser with this strategy:
{"foo": 1} // first top-level JSON object
"bar" 42 3.14
[]
public static JsonParserTopLevelStrategy[] values()
for (JsonParserTopLevelStrategy c : JsonParserTopLevelStrategy.values()) System.out.println(c);
public static JsonParserTopLevelStrategy valueOf(String name)
name - the name of the enum constant to be returned.IllegalArgumentException - if this enum type has no constant
with the specified nameNullPointerException - if the argument is nullCopyright © 2014. All rights reserved.