Java tutorial
//package com.java2s; import java.util.Iterator; import java.util.ArrayList; import org.json.JSONObject; public class Main { public static String[] getJSONObjectKeys(JSONObject inputObject) { Iterator keys = inputObject.keys(); ArrayList<String> objectKeys = new ArrayList<String>(); while (keys != null && keys.hasNext()) { objectKeys.add((String) keys.next()); } String[] returnArray = new String[objectKeys.size()]; return objectKeys.toArray(returnArray); } }