/** * Consume the next character, and check that it matches a specified * character.<p> * * @param c the character to match * @return the character * @throws JSONException if the character does not match */ public char next(char c) throws JSONException { char n = next(); if (n != c) { throw syntaxError("Expected '" + c + "' and instead saw '" + n + "'"); } return n; }
/** * Consume the next character, and check that it matches a specified * character.<p> * * @param c the character to match * @return the character * @throws JSONException if the character does not match */ public char next(char c) throws JSONException { char n = next(); if (n != c) { throw syntaxError("Expected '" + c + "' and instead saw '" + n + "'"); } return n; }
throw syntaxError("Substring bounds error");
throw syntaxError("Substring bounds error");
case '\n': case '\r': throw syntaxError("Unterminated string"); case '\\': c = next();
case '\n': case '\r': throw syntaxError("Unterminated string"); case '\\': c = next();
throw syntaxError("Missing value");
throw syntaxError("Missing value");
q = ')'; } else { throw x.syntaxError("A JSONArray text must start with '['"); case ')': if (q != c) { throw x.syntaxError("Expected a '" + new Character(q) + "'"); throw x.syntaxError("Expected a ',' or ']'");
q = ')'; } else { throw x.syntaxError("A JSONArray text must start with '['"); case ')': if (q != c) { throw x.syntaxError("Expected a '" + new Character(q) + "'"); throw x.syntaxError("Expected a ',' or ']'");
throw x.syntaxError("A JSONObject text must begin with '{'"); switch (c) { case 0: throw x.syntaxError("A JSONObject text must end with '}'"); case '}': return; throw x.syntaxError("Expected a ':' after a key"); return; default: throw x.syntaxError("Expected a ',' or '}'");
throw x.syntaxError("A JSONObject text must begin with '{'"); switch (c) { case 0: throw x.syntaxError("A JSONObject text must end with '}'"); case '}': return; throw x.syntaxError("Expected a ':' after a key"); return; default: throw x.syntaxError("Expected a ',' or '}'");
/** * Produce a JSONArray of strings from a row of comma delimited values.<p> * * @param x A JSONTokener of the source text * @return A JSONArray of strings * @throws JSONException if something goes wrong */ public static JSONArray rowToJSONArray(JSONTokener x) throws JSONException { JSONArray ja = new JSONArray(); for (;;) { String value = getValue(x); if (value == null || (ja.length() == 0 && value.length() == 0)) { return null; } ja.put(value); for (;;) { char c = x.next(); if (c == ',') { break; } if (c != ' ') { if (c == '\n' || c == '\r' || c == 0) { return ja; } throw x.syntaxError("Bad character '" + c + "' (" + (int)c + ")."); } } } }
/** * Produce a JSONArray of strings from a row of comma delimited values.<p> * * @param x A JSONTokener of the source text * @return A JSONArray of strings * @throws JSONException if something goes wrong */ public static JSONArray rowToJSONArray(JSONTokener x) throws JSONException { JSONArray ja = new JSONArray(); for (;;) { String value = getValue(x); if ((value == null) || ((ja.length() == 0) && (value.length() == 0))) { return null; } ja.put(value); for (;;) { char c = x.next(); if (c == ',') { break; } if (c != ' ') { if ((c == '\n') || (c == '\r') || (c == 0)) { return ja; } throw x.syntaxError("Bad character '" + c + "' (" + (int)c + ")."); } } } }
c = next(); if (c == 0) { throw syntaxError("Unclosed comment");
c = next(); if (c == 0) { throw syntaxError("Unclosed comment");