public enum JsonParserType extends Enum<JsonParserType>
parser = new JsonSlurper().setType( JsonParserType.INDEX_OVERLAY );
INDEX_OVERLAY should be your parser of choice.
CHAR_BUFFER is the parser of choice due to element of least surprise and need to
mimic existing Slurper behavior as much as possible.
Use CHARACTER_SOURCE for large file parsing.
Use LAX if you want to enable relaxed JSON parsing, i.e., allow comments, no quote strings, etc.
Use CHAR_BUFFER for a non-fancy but super fast parser.
Parser speed in order: INDEX_OVERLAY, LAX, CHAR_BUFFER, CHARACTER_SOURCE.
Use Cases:Use LAX for config files as it allows comments. Use INDEX_OVERLAY for REST calls, WebSocket messages, AJAX, inter process communication, etc. Use CHAR_BUFFER if eager parsing of ints, dates, longs, are appealing. Use CHARACTER_SOURCE if you are dealing with large JSON files over 2MB. INDEX_OVERLAY is highly tuned for object deserialization from JSON.
Enum Constant and Description |
---|
CHAR_BUFFER
This is a basic parser with no index overlay.
|
CHARACTER_SOURCE
Parser uses an abstraction that allows it to handle any size file by using a char [] windowing,
built on top or Reader.
|
INDEX_OVERLAY
Fastest parser, but has pointers (indexes really) to original char buffer.
|
LAX
LAX mode allows keys with no quotes, keys with single quotes,
strings elements in JSON with no quotes or single quotes.
|
Modifier and Type | Method and Description |
---|---|
static JsonParserType |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static JsonParserType[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final JsonParserType INDEX_OVERLAY
public static final JsonParserType CHARACTER_SOURCE
public static final JsonParserType LAX
public static final JsonParserType CHAR_BUFFER
public static JsonParserType[] values()
for (JsonParserType c : JsonParserType.values()) System.out.println(c);
public static JsonParserType 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 null