/** * Get an array of field names from a JSONObject. * * @return An array of field names, or null if there are no names. */ public static String[] getNames(final JSONObject jo) { int length = jo.length(); if (length == 0) { return null; } Iterator i = jo.keys(); String[] names = new String[length]; int j = 0; while (i.hasNext()) { names[j] = (String)i.next(); j += 1; } return names; }
/** * Get an array of field names from a JSONObject. * * @return An array of field names, or null if there are no names. */ public static String[] getNames(final JSONObject jo) { int length = jo.length(); if (length == 0) { return null; } Iterator i = jo.keys(); String[] names = new String[length]; int j = 0; while (i.hasNext()) { names[j] = (String)i.next(); j += 1; } return names; }
/** * Produce a JSONArray containing the names of the elements of this * JSONObject. * @return A JSONArray containing the key strings, or null if the JSONObject * is empty. */ public JSONArray names() { JSONArray ja = new JSONArray(); Iterator keys = keys(); while (keys.hasNext()) { ja.put(keys.next()); } return ja.length() == 0 ? null : ja; }
/** * Produce a JSONArray containing the names of the elements of this * JSONObject. * @return A JSONArray containing the key strings, or null if the JSONObject * is empty. */ public JSONArray names() { JSONArray ja = new JSONArray(); Iterator keys = keys(); while (keys.hasNext()) { ja.put(keys.next()); } return ja.length() == 0 ? null : ja; }
Iterator keys = keys(); StringBuffer sb = new StringBuffer("{");
Iterator keys = keys(); StringBuilder sb = new StringBuilder("{");
Iterator keys = keys(); writer.write('{');
Iterator keys = keys(); writer.write('{');
StringBuilder propstr = new StringBuilder(); @SuppressWarnings("unchecked") Iterator<String> propkeys = props.keys(); while (propkeys.hasNext())
StringBuilder propstr = new StringBuilder(); @SuppressWarnings("unchecked") Iterator<String> propkeys = props.keys(); while (propkeys.hasNext())
StringBuilder propstr = new StringBuilder(); @SuppressWarnings("unchecked") Iterator<String> propkeys = props.keys(); while (propkeys.hasNext())