java.lang.Object
jsonvalues.spec.JsReader
Object for processing JSON from byte[] and InputStream. The only public methods are
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)
-
Method Summary
Modifier and TypeMethodDescriptionbyte
Read next token (byte) from input JSON.void
reset()
Reset reader after processing input It will release reference to provided byte[] or InputStream input
-
Method Details
-
reset
public void reset()Reset reader after processing input It will release reference to provided byte[] or InputStream input -
readNextToken
Read next token (byte) from input JSON. Whitespace will be skipped and next non-whitespace byte will be returned.- Returns:
- next non-whitespace byte in the JSON input
- Throws:
JsParserException
- unable to get next byte (end of stream, ...)
-