public final class JsReader extends Object
readNextToken()
and reset()
. Most of the time you don't need to
parse a JSON token by token since there are a lot of high-level and efficient alternatives
implemented in json-values. Just in case, find below an example:
String json = "[1,2,3]";
var reader = JsonIO.INSTANCE.createReader(json.getBytes(StandardCharsets.UTF_8));
byte token;
while ((token = reader.readNextToken()) != ']'){
if(Character.isDigit(token)) System.out.println(Character.toString(token));
}
You can also read tokens as JsValue and validate them using the method JsSpec.readNextValue(JsReader)
Modifier and Type | Method and Description |
---|---|
byte |
readNextToken()
Read next token (byte) from input JSON.
|
void |
reset()
Reset reader after processing input
It will release reference to provided byte[] or InputStream input
|
public void reset()
public byte readNextToken() throws JsParserException
JsParserException
- unable to get next byte (end of stream, ...)Copyright © 2023. All rights reserved.