[Java] Class JsonLexer
- groovy.json.JsonLexer
- All Implemented Interfaces and Traits:
- Iterator
public class JsonLexer
The lexer reads JSON tokens in a streaming fashion from the underlying reader.
- Authors:
- Guillaume Laforge
- Since:
- 1.8.0
Constructor Summary
Constructor and description |
---|
JsonLexer
(Reader reader) Instantiates a lexer with a reader from which to read JSON tokens. |
Methods Summary
Type Params | Return Type | Name and description |
---|---|---|
LineColumnReader |
getReader() Underlying reader from which to read the JSON tokens. | |
boolean |
hasNext() Iterator method to know if another token follows, or if we've reached the end of the stream. | |
JsonToken |
next() Iterator method to get the next token of the stream. | |
JsonToken |
nextToken() @return the next token from the stream | |
void |
remove() Method not implemented. | |
int |
skipWhitespace() Skips all the whitespace characters and moves the cursor to the next non-space character. | |
static String |
unescape(String input) Replace unicode escape and other control characters with real characters |
Inherited Methods Summary
Methods inherited from class | Name |
---|---|
class Object | wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
Constructor Detail
public JsonLexer(Reader reader)
Instantiates a lexer with a reader from which to read JSON tokens. Under the hood, the reader is wrapped in a LineColumnReader
, for line and column information, unless it's already an instance of that class.
- Parameters:
-
reader
- underlying reader
Method Detail
public LineColumnReader getReader()
Underlying reader from which to read the JSON tokens. This reader is an instance of LineColumnReader
, to keep track of line and column positions.
public boolean hasNext()
Iterator method to know if another token follows, or if we've reached the end of the stream.
- Returns:
- true if there are more tokens
public JsonToken next()
Iterator method to get the next token of the stream.
- Returns:
- the next token
public JsonToken nextToken()
- Returns:
- the next token from the stream
public void remove()
Method not implemented.
- throws:
- UnsupportedOperationException
public int skipWhitespace()
Skips all the whitespace characters and moves the cursor to the next non-space character.
public static String unescape(String input)
Replace unicode escape and other control characters with real characters
- Parameters:
-
input
- text
- Returns:
- input text without the escaping
© 2003-2020 The Apache Software Foundation
Licensed under the Apache license.
https://docs.groovy-lang.org/2.4.21/html/gapi/groovy/json/JsonLexer.html