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.
()
| 1016 | * is empty. |
| 1017 | */ |
| 1018 | public JSONArray names() { |
| 1019 | JSONArray ja = new JSONArray(); |
| 1020 | Iterator<String> keys = this.keys(); |
| 1021 | while (keys.hasNext()) { |
| 1022 | ja.put(keys.next()); |
| 1023 | } |
| 1024 | return ja.length() == 0 ? null : ja; |
| 1025 | } |
| 1026 | |
| 1027 | /** |
| 1028 | * Get an optional value associated with a key. |