if (x.nextClean() != '[') { throw x.syntaxError("A JSONArray text must start with '['"); if (x.nextClean() != ']') { x.back(); for (;;) { if (x.nextClean() == ',') { x.back(); this.myArrayList.add(JSONObject.NULL); this.myArrayList.add(x.nextValue()); switch (x.nextClean()) { case ',': if (x.nextClean() == ']') { return;
private Object parse(String json) throws JSONException { JSONTokener tokener = new JSONTokener(json); char c = tokener.nextClean(); //peak ahead tokener.back(); //revert if (c == '{') { //json object JSONObject o = new JSONObject(tokener); return toMap(o); } else if (c == '[') { JSONArray a = new JSONArray(tokener); return toList(a); } else { //raw json value Object value = tokener.nextValue(); return convertIfNecessary(value); } }
if (x.nextClean() != '[') { throw x.syntaxError("A JSONArray text must start with '['"); if (x.nextClean() != ']') { x.back(); for (;;) { if (x.nextClean() == ',') { x.back(); this.myArrayList.add(JSONObject.NULL); this.myArrayList.add(x.nextValue()); switch (x.nextClean()) { case ',': if (x.nextClean() == ']') { return;
String key; if (x.nextClean() != '{') { throw x.syntaxError("A JSONObject text must begin with '{'"); c = x.nextClean(); switch (c) { case 0: c = x.nextClean(); if (c != ':') { throw x.syntaxError("Expected a ':' after a key"); switch (x.nextClean()) { case ';': case ',': if (x.nextClean() == '}') { return;
char c = this.nextClean(); String string;
String key; if (x.nextClean() != '{') { throw x.syntaxError("A JSONObject text must begin with '{'"); c = x.nextClean(); switch (c) { case 0: c = x.nextClean(); if (c != ':') { throw x.syntaxError("Expected a ':' after a key"); switch (x.nextClean()) { case ';': case ',': if (x.nextClean() == '}') { return;
char c = this.nextClean(); String string;
if (x.nextClean() != '[') { throw x.syntaxError("A JSONArray text must start with '['"); char nextChar = x.nextClean(); if (nextChar == 0) { x.back(); for (;;) { if (x.nextClean() == ',') { x.back(); this.myArrayList.add(JSONObject.NULL); this.myArrayList.add(x.nextValue()); switch (x.nextClean()) { case 0: nextChar = x.nextClean(); if (nextChar == 0) {
String key; if (x.nextClean() != '{') { throw x.syntaxError("A JSONObject text must begin with '{'"); c = x.nextClean(); switch (c) { case 0: c = x.nextClean(); if (c != ':') { throw x.syntaxError("Expected a ':' after a key"); switch (x.nextClean()) { case ';': case ',': if (x.nextClean() == '}') { return;
char c = this.nextClean(); String string;
public static void createSequenceFileFromJSON(FSDataInputStream fsDataInputStream, FSDataOutputStream fsDataOutputStream) throws IOException { JSONTokener tokener = new JSONTokener(new InputStreamReader(fsDataInputStream, "UTF-8")); PrintWriter pw = new PrintWriter(fsDataOutputStream); pw.println("["); tokener.nextClean(); char tmp = '['; while(tmp != ']') { JSONObject obj = (JSONObject) tokener.nextValue(); processJSONObject(obj); pw.println(obj.toString(4)); tmp = tokener.nextClean(); if (tmp != ']') { pw.println(","); } } pw.println("]"); pw.close(); }
public static void processJsonStream(JsonEntityResponseHandler handler, InputStream stream) throws IOException { JSONTokener tokener = new JSONTokener(stream); while (true) { char next = tokener.nextClean(); if (next == 0) { return; } else { tokener.back(); } JSONObject object = new JSONObject(tokener); handler.process(object); } }
if (x.nextClean() != '[') { throw x.syntaxError("A JSONArray text must start with '['"); if (x.nextClean() != ']') { x.back(); for (;;) { if (x.nextClean() == ',') { x.back(); this.myArrayList.add(JSONObject.NULL); this.myArrayList.add(x.nextValue()); switch (x.nextClean()) { case ';': case ',': if (x.nextClean() == ']') { return;
if (x.nextClean() != '[') { throw x.syntaxError("A JSONArray text must start with '['"); if (x.nextClean() != ']') { x.back(); for (; ; ) { if (x.nextClean() == ',') { x.back(); this.myArrayList.add(JSONObject.NULL); this.myArrayList.add(x.nextValue()); switch (x.nextClean()) { case ';': case ',': if (x.nextClean() == ']') { return;
if (x.nextClean() != '[') { throw x.syntaxError("A JSONArray text must start with '['"); if (x.nextClean() != ']') { x.back(); for (;;) { if (x.nextClean() == ',') { x.back(); this.myArrayList.add(JSONObject.NULL); this.myArrayList.add(x.nextValue()); switch (x.nextClean()) { case ';': case ',': if (x.nextClean() == ']') { return;
if (x.nextClean() != '[') { throw x.syntaxError("A JSONArray text must start with '['"); if (x.nextClean() != ']') { x.back(); for (;;) { if (x.nextClean() == ',') { x.back(); this.myArrayList.add(JSONObject.NULL); this.myArrayList.add(x.nextValue()); switch (x.nextClean()) { case ';': case ',': if (x.nextClean() == ']') { return;
char c = token.nextClean(); while (c != '}') { if (maxNumLines > 0 && numObjects >= maxNumLines) token.back(); Object key = token.nextValue(); char t = token.nextClean(); if (t != ':') throw new JSONException("Parse JSON object error"); if (maxNumLines > 0 && numObjects >= maxNumLines) break; c = token.nextClean(); if (c != ',' && c != '}') throw new JSONException("Parse JSON object error"); if (c == ',') { c = token.nextClean();
/** * Get {@link Properties} for a given {@code inputStream} treating it as a JSON file. * * @param inputStream input stream representing JSON file * @return properties representing values from {@code inputStream} * @throws IllegalStateException when unable to read properties */ @Override public Properties getProperties(InputStream inputStream) { requireNonNull(inputStream); Properties properties = new Properties(); try { JSONTokener tokener = new JSONTokener(inputStream); if (tokener.end()) { return properties; } if (tokener.nextClean() == '"') { tokener.back(); properties.put("content", tokener.nextValue().toString()); } else { tokener.back(); JSONObject obj = new JSONObject(tokener); Map<String, Object> yamlAsMap = convertToMap(obj); properties.putAll(flatten(yamlAsMap)); } return properties; } catch (Exception e) { throw new IllegalStateException("Unable to load json configuration from provided stream", e); } }
private Object parse(String json) throws JSONException { JSONTokener tokener = new JSONTokener(json); char c = tokener.nextClean(); //peak ahead tokener.back(); //revert if (c == '{') { //json object JSONObject o = new JSONObject(tokener); return toMap(o); } else if (c == '[') { JSONArray a = new JSONArray(tokener); return toList(a); } else { //raw json value Object value = tokener.nextValue(); return convertIfNecessary(value); } }
char c = nextClean(); String s;