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.
Enum constant | Description |
---|---|
CHARACTER_SOURCE |
|
CHAR_BUFFER |
|
INDEX_OVERLAY |
|
LAX |
Copyright © 2003-2018 The Apache Software Foundation. All rights reserved.