A JSONObject stores JSON data with multiple name/value pairs. Values can be numeric, Strings , booleans , other JSONObject s or JSONArray s, or null. JSONObject and JSONArray objects are quite similar and share most of the same methods; the primary differ
| 124 | * @see PApplet#saveJSONArray(JSONArray, String) |
| 125 | */ |
| 126 | public class JSONObject { |
| 127 | /** |
| 128 | * The maximum number of keys in the key pool. |
| 129 | */ |
| 130 | private static final int keyPoolSize = 100; |
| 131 | |
| 132 | /** |
| 133 | * Key pooling is like string interning, but without permanently tying up |
| 134 | * memory. To help conserve memory, storage of duplicated key strings in |
| 135 | * JSONObjects will be avoided by using a key pool to manage unique key |
| 136 | * string objects. This is used by JSONObject.put(string, object). |
| 137 | */ |
| 138 | private static HashMap<String, Object> keyPool = |
| 139 | new HashMap<>(keyPoolSize); |
| 140 | |
| 141 | |
| 142 | // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
| 143 | |
| 144 | |
| 145 | /** |
| 146 | * JSONObject.NULL is equivalent to the value that JavaScript calls null, |
| 147 | * whilst Java's null is equivalent to the value that JavaScript calls |
| 148 | * undefined. |
| 149 | */ |
| 150 | private static final class Null { |
| 151 | /** |
| 152 | * There is only intended to be a single instance of the NULL object, |
| 153 | * so the clone method returns itself. |
| 154 | * @return NULL. |
| 155 | */ |
| 156 | @Override |
| 157 | protected final Object clone() { |
| 158 | return this; |
| 159 | } |
| 160 | |
| 161 | /** |
| 162 | * A Null object is equal to the null value and to itself. |
| 163 | * @param object An object to test for nullness. |
| 164 | * @return true if the object parameter is the JSONObject.NULL object |
| 165 | * or null. |
| 166 | */ |
| 167 | @Override |
| 168 | public boolean equals(Object object) { |
| 169 | return object == null || object == this; |
| 170 | } |
| 171 | |
| 172 | /** |
| 173 | * Get the "null" string value. |
| 174 | * @return The string "null". |
| 175 | */ |
| 176 | @Override |
| 177 | public String toString() { |
| 178 | return "null"; |
| 179 | } |
| 180 | |
| 181 | @Override |
| 182 | public int hashCode() { |
| 183 | // TODO Auto-generated method stub |
nothing calls this directly
no outgoing calls
no test coverage detected