private void consume(char token) throws ParseException { consumeWhitespace(); if (pos >= length) { throw new ParseException("Expected " + token + " but reached end of stream"); } char c = src.charAt(pos++); if (c == token) { return; } else { throw new ParseException("Expected " + token + " found " + c); } }
public synchronized Object parseValue(String json) throws ParseException { if (json == null) { throw new ParseException("Input string may not be null"); } pos = 0; length = json.length(); src = json; Object value = readValue(); consumeWhitespace(); if (pos < length) { throw new ParseException("Expected end of stream at char " + pos); } return value; }
private static Object parse(Context cx, Scriptable scope, String jtext) { try { return new JsonParser(cx, scope).parseValue(jtext); } catch (JsonParser.ParseException ex) { throw ScriptRuntime.constructError("SyntaxError", ex.getMessage()); } }
private Boolean readTrue() throws ParseException { if (length - pos < 3 || src.charAt(pos) != 'r' || src.charAt(pos + 1) != 'u' || src.charAt(pos + 2) != 'e') { throw new ParseException("Unexpected token: t"); } pos += 3; return Boolean.TRUE; }
private char nextOrNumberError(int numberStart) throws ParseException { if (pos >= length) { throw numberError(numberStart, length); } return src.charAt(pos++); }
private static Object parse(Context cx, Scriptable scope, String jtext) { try { return new JsonParser(cx, scope).parseValue(jtext); } catch (JsonParser.ParseException ex) { throw ScriptRuntime.constructError("SyntaxError", ex.getMessage()); } }
public synchronized Object parseValue(String json) throws ParseException { if (json == null) { throw new ParseException("Input string may not be null"); } pos = 0; length = json.length(); src = json; Object value = readValue(); consumeWhitespace(); if (pos < length) { throw new ParseException("Expected end of stream at char " + pos); } return value; }
private void consume(char token) throws ParseException { consumeWhitespace(); if (pos >= length) { throw new ParseException("Expected " + token + " but reached end of stream"); } char c = src.charAt(pos++); if (c == token) { return; } else { throw new ParseException("Expected " + token + " found " + c); } }
private Boolean readTrue() throws ParseException { if (length - pos < 3 || src.charAt(pos) != 'r' || src.charAt(pos + 1) != 'u' || src.charAt(pos + 2) != 'e') { throw new ParseException("Unexpected token: t"); } pos += 3; return Boolean.TRUE; }
private char nextOrNumberError(int numberStart) throws ParseException { if (pos >= length) { throw numberError(numberStart, length); } return src.charAt(pos++); }
private static Object parse(Context cx, Scriptable scope, String jtext) { try { return new JsonParser(cx, scope).parseValue(jtext); } catch (JsonParser.ParseException ex) { throw ScriptRuntime.constructError("SyntaxError", ex.getMessage()); } }
public synchronized Object parseValue(String json) throws ParseException { if (json == null) { throw new ParseException("Input string may not be null"); } pos = 0; length = json.length(); src = json; Object value = readValue(); consumeWhitespace(); if (pos < length) { throw new ParseException("Expected end of stream at char " + pos); } return value; }
private void consume(char token) throws ParseException { consumeWhitespace(); if (pos >= length) { throw new ParseException("Expected " + token + " but reached end of stream"); } char c = src.charAt(pos++); if (c == token) { return; } else { throw new ParseException("Expected " + token + " found " + c); } }
private Object readNull() throws ParseException { if (length - pos < 3 || src.charAt(pos) != 'u' || src.charAt(pos + 1) != 'l' || src.charAt(pos + 2) != 'l') { throw new ParseException("Unexpected token: n"); } pos += 3; return null; }
private char nextOrNumberError(int numberStart) throws ParseException { if (pos >= length) { throw numberError(numberStart, length); } return src.charAt(pos++); }
private static Object parse(Context cx, Scriptable scope, String jtext) { try { return new JsonParser(cx, scope).parseValue(jtext); } catch (JsonParser.ParseException ex) { throw ScriptRuntime.constructError("SyntaxError", ex.getMessage()); } }
public synchronized Object parseValue(String json) throws ParseException { if (json == null) { throw new ParseException("Input string may not be null"); } pos = 0; length = json.length(); src = json; Object value = readValue(); consumeWhitespace(); if (pos < length) { throw new ParseException("Expected end of stream at char " + pos); } return value; }
private void consume(char token) throws ParseException { consumeWhitespace(); if (pos >= length) { throw new ParseException("Expected " + token + " but reached end of stream"); } char c = src.charAt(pos++); if (c == token) { return; } else { throw new ParseException("Expected " + token + " found " + c); } }
private Boolean readTrue() throws ParseException { if (length - pos < 3 || src.charAt(pos) != 'r' || src.charAt(pos + 1) != 'u' || src.charAt(pos + 2) != 'e') { throw new ParseException("Unexpected token: t"); } pos += 3; return Boolean.TRUE; }
private Boolean readFalse() throws ParseException { if (length - pos < 4 || src.charAt(pos) != 'a' || src.charAt(pos + 1) != 'l' || src.charAt(pos + 2) != 's' || src.charAt(pos + 3) != 'e') { throw new ParseException("Unexpected token: f"); } pos += 4; return Boolean.FALSE; }