Example #1
0
 /**
  * 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(JSONObject jo) {
   final int length = jo.length();
   if (length == 0) {
     return null;
   }
   final Iterator iterator = jo.keys();
   final String[] names = new String[length];
   int i = 0;
   while (iterator.hasNext()) {
     names[i] = (String) iterator.next();
     i += 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(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;
 }