private void readRequiredChar(char ch) throws IOException { if (!readIf(ch)) { throw expected("'"+ch+"'"); } }
private void readRequiredChar(char ch) throws IOException { if (!readIf(ch)) { throw expected("'"+ch+"'"); } }
private boolean readFraction() throws IOException { if (!readIf('.')) { return false; } if (!readDigit()) { throw expected("digit"); } while (readDigit()) { } return true; }
private boolean readFraction() throws IOException { if (!readIf('.')) { return false; } if (!readDigit()) { throw expected("digit"); } while (readDigit()) { } return true; }
private JsonArray readArray() throws IOException { read(); JsonArray array=new JsonArray(); skipWhiteSpace(); if (readIf(']')) { return array; } do { skipWhiteSpace(); array.add(readValue()); skipWhiteSpace(); } while (readIf(',')); if (!readIf(']')) { throw expected("',' or ']'"); } return array; }
private JsonArray readArray() throws IOException { read(); JsonArray array=new JsonArray(); skipWhiteSpace(); if (readIf(']')) { return array; } do { skipWhiteSpace(); array.add(readValue()); skipWhiteSpace(); } while (readIf(',')); if (!readIf(']')) { throw expected("',' or ']'"); } return array; }
private JsonObject readObject() throws IOException { read(); JsonObject object=new JsonObject(); skipWhiteSpace(); if (readIf('}')) { return object; } do { skipWhiteSpace(); String name=readName(); skipWhiteSpace(); if (!readIf(':')) { throw expected("':'"); } skipWhiteSpace(); object.add(name, readValue()); skipWhiteSpace(); } while (readIf(',')); if (!readIf('}')) { throw expected("',' or '}'"); } return object; }
private JsonObject readObject() throws IOException { read(); JsonObject object=new JsonObject(); skipWhiteSpace(); if (readIf('}')) { return object; } do { skipWhiteSpace(); String name=readName(); skipWhiteSpace(); if (!readIf(':')) { throw expected("':'"); } skipWhiteSpace(); object.add(name, readValue()); skipWhiteSpace(); } while (readIf(',')); if (!readIf('}')) { throw expected("',' or '}'"); } return object; }
private JsonValue readNumber() throws IOException { startCapture(); readIf('-'); int firstDigit=current; if (!readDigit()) { throw expected("digit"); } if (firstDigit!='0') { while (readDigit()) { } } readFraction(); readExponent(); return new JsonNumber(Double.parseDouble(endCapture())); }
private JsonValue readNumber() throws IOException { startCapture(); readIf('-'); int firstDigit=current; if (!readDigit()) { throw expected("digit"); } if (firstDigit!='0') { while (readDigit()) { } } readFraction(); readExponent(); return new JsonNumber(Double.parseDouble(endCapture())); }