Home | History | Annotate | Download | only in json

Lines Matching defs:JSONObject

39  * A JSONObject is an unordered collection of name/value pairs. Its
45 * <code>Boolean</code>, <code>JSONArray</code>, <code>JSONObject</code>,
46 * <code>Number</code>, <code>String</code>, or the <code>JSONObject.NULL</code>
47 * object. A JSONObject constructor can be used to convert an external form
62 * myString = new JSONObject().put("JSON", "Hello, World!").toString();</pre>
89 public class JSONObject {
92 * JSONObject.NULL is equivalent to the value that JavaScript calls null,
111 * @return true if the object parameter is the JSONObject.NULL object
130 * The map where the JSONObject's properties are kept.
138 * <code>JSONObject.NULL.equals(null)</code> returns <code>true</code>.
139 * <code>JSONObject.NULL.toString()</code> returns <code>"null"</code>.
145 * Construct an empty JSONObject.
147 public JSONObject() {
153 * Construct a JSONObject from a subset of another JSONObject.
156 * @param jo A JSONObject.
160 public JSONObject(JSONObject jo, String[] names) throws JSONException {
169 * Construct a JSONObject from a JSONTokener.
174 public JSONObject(JSONTokener x) throws JSONException {
180 throw x.syntaxError("A JSONObject text must begin with '{'");
186 throw x.syntaxError("A JSONObject text must end with '}'");
230 * Construct a JSONObject from a Map.
233 * the JSONObject.
235 public JSONObject(Map map) {
241 * Construct a JSONObject from a Map.
248 public JSONObject(Map map, boolean includeSuperClass) {
257 this.map.put(e.getKey(), new JSONObject(e.getValue(),
266 * Construct a JSONObject from an Object using bean getters.
271 * are put into the new JSONObject.
279 * then the JSONObject will contain <code>"name": "Larry Fine"</code>.
282 * to make a JSONObject.
284 public JSONObject(Object bean) {
291 * Construct a JSONObject from an Object using bean getters.
296 * are put into the new JSONObject.
303 * to make a JSONObject.
306 public JSONObject(Object bean, boolean includeSuperClass) {
351 map.put(key, new JSONObject((Map)result, includeSuperClass));
359 map.put(key, new JSONObject(result, includeSuperClass));
386 * Construct a JSONObject from an Object, using reflection to find the
387 * public members. The resulting JSONObject's keys will be the strings
390 * then it will not be copied into the new JSONObject.
392 * JSONObject.
396 public JSONObject(Object object, String names[]) {
411 * Construct a JSONObject from a source JSON text string.
412 * This is the most commonly used JSONObject constructor.
419 public JSONObject(String source) throws JSONException {
436 public JSONObject accumulate(String key, Object value)
455 * JSONObject, then the key is put in the JSONObject with its value being a
464 public JSONObject append(String key, Object value)
473 throw new JSONException("JSONObject[" + key +
516 throw new JSONException("JSONObject[" + quote(key) +
542 throw new JSONException("JSONObject[" + quote(key) +
561 throw new JSONException("JSONObject[" + quote(key) +
596 throw new JSONException("JSONObject[" + quote(key) +
602 * Get the JSONObject value associated with a key.
605 * @return A JSONObject which is the value.
607 * if the value is not a JSONObject.
609 public JSONObject getJSONObject(String key) throws JSONException {
611 if (o instanceof JSONObject) {
612 return (JSONObject)o;
614 throw new JSONException("JSONObject[" + quote(key) +
615 "] is not a JSONObject.");
636 * Get an array of field names from a JSONObject.
640 public static String[] getNames(JSONObject jo) {
692 * Determine if the JSONObject contains a specific key.
694 * @return true if the key exists in the JSONObject.
706 * the value is the JSONObject.NULL object.
709 return JSONObject.NULL.equals(opt(key));
714 * Get an enumeration of the keys of the JSONObject.
724 * Get the number of keys stored in the JSONObject.
726 * @return The number of keys in the JSONObject.
735 * JSONObject.
736 * @return A JSONArray containing the key strings, or null if the JSONObject
818 * Put a key/value pair in the JSONObject, where the value will be a
825 public JSONObject put(String key, Collection value) throws JSONException {
914 * Get an optional JSONObject associated with a key.
916 * JSONObject.
919 * @return A JSONObject which is the value.
921 public JSONObject optJSONObject(String key) {
923 return o instanceof JSONObject ? (JSONObject)o : null;
988 * Put a key/boolean pair in the JSONObject.
995 public JSONObject put(String key, boolean value) throws JSONException {
1002 * Put a key/double pair in the JSONObject.
1009 public JSONObject put(String key, double value) throws JSONException {
1016 * Put a key/int pair in the JSONObject.
1023 public JSONObject put(String key, int value) throws JSONException {
1030 * Put a key/long pair in the JSONObject.
1037 public JSONObject put(String key, long value) throws JSONException {
1044 * Put a key/value pair in the JSONObject, where the value will be a
1045 * JSONObject which is produced from a Map.
1051 public JSONObject put(String key, Map value) throws JSONException {
1052 put(key, new JSONObject(value));
1058 * Put a key/value pair in the JSONObject. If the value is null,
1059 * then the key will be removed from the JSONObject if it is present.
1062 * types: Boolean, Double, Integer, JSONArray, JSONObject, Long, String,
1063 * or the JSONObject.NULL object.
1068 public JSONObject put(String key, Object value) throws JSONException {
1083 * Put a key/value pair in the JSONObject, but only if the key and the
1091 public JSONObject putOnce(String key, Object value) throws JSONException {
1103 * Put a key/value pair in the JSONObject, but only if the
1107 * types: Boolean, Double, Integer, JSONArray, JSONObject, Long, String,
1108 * or the JSONObject.NULL object.
1112 public JSONObject putOpt(String key, Object value) throws JSONException {
1196 * Get an enumeration of the keys of the JSONObject.
1222 return JSONObject.NULL;
1295 * JSONObject.
1313 * Make a JSON text of this JSONObject. For compactness, no whitespace
1347 * Make a prettyprinted JSON text of this JSONObject.
1364 * Make a prettyprinted JSON text of this JSONObject.
1428 * will be called. If the value is a MAP, then a JSONObject will be made
1460 if (value instanceof Boolean || value instanceof JSONObject ||
1465 return new JSONObject((Map)value).toString();
1512 if (value instanceof JSONObject) {
1513 return ((JSONObject)value).toString(indentFactor, indent);
1519 return new JSONObject((Map)value).toString(indentFactor, indent);
1532 * Write the contents of the JSONObject as JSON text to a writer.
1554 if (v instanceof JSONObject) {
1555 ((JSONObject)v).write(writer);