[Java] Enum JsonParserType
- groovy.json.JsonParserType
Allows selection of parser type for new new JsonSlurper.
To enable the INDEX_OVERLAY parser do this:
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.
- Authors:
- Rick Hightower
- Since:
- 2.3.0
Enum Constants Summary
Enum constant | Description |
---|---|
CHARACTER_SOURCE | |
CHAR_BUFFER | |
INDEX_OVERLAY | |
LAX |
Inherited Methods Summary
Methods inherited from class | Name |
---|---|
class Object | wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
Enum Constant Detail
JsonParserType CHARACTER_SOURCE
JsonParserType CHAR_BUFFER
JsonParserType INDEX_OVERLAY
JsonParserType LAX
© 2003-2020 The Apache Software Foundation
Licensed under the Apache license.
https://docs.groovy-lang.org/2.4.21/html/gapi/groovy/json/JsonParserType.html