Title: Theory / Unimportant / CS / Programming / Java / Android / Lib / JSON
Tags: seen_description automatedNewLineAfterCommaSpace
On every note of this deck, unless a note says otherwise:
Language: Java

Instruction: JSONObject()
Page: https://developer.android.com/reference/org/json/JSONObject
Returns: An empty object for JSON

Instruction: JSONObject(s)
Page: https://developer.android.com/reference/org/json/JSONObject
Context: s a string
Returns: The JSONObject encoded by s

Instruction: JSONObject(m)
Page: https://developer.android.com/reference/org/json/JSONObject
Context: m a map
Returns: The JSONObject similar to m
Assuming: entries are string,
values are supported by JSON

Instruction: JSONObject(
  obj,
  names
)
Page: https://developer.android.com/reference/org/json/JSONObject
Context: obj a JSONObject
names an array of string
Returns: A JSONObject similar to obj with only names entries

Instruction: obj.get(name);
Page: https://developer.android.com/reference/org/json/JSONObject
Context: obj a JSONObject
name a string
Returns: the Object in obj assigned to name
Exception: JSONException if no such mapping exists.

Instruction: obj.gettyp(name);
Page: https://developer.android.com/reference/org/json/JSONObject
Context: obj a JSONObject
name a string
typ a type
Returns: The typ in obj assigned to name
Exception: JSONException if no such mapping exists or if it can't be coerced to type typ

Instruction: obj.has(name);
Page: https://developer.android.com/reference/org/json/JSONObject
Context: obj a JSONObject
name a string
Returns: Whether there is an entry for name in obj

Instruction: obj.length();
Page: https://developer.android.com/reference/org/json/JSONObject
Context: obj a JSONObject
name a string
Returns: The number of entries in obj

Instruction: obj.isNull(name);
Page: https://developer.android.com/reference/org/json/JSONObject
Context: obj a JSONObject
name a string
Returns: Whether the entry at value name is null

Instruction: obj.keys();
Page: https://developer.android.com/reference/org/json/JSONObject
Context: obj a JSONObject
Returns: An iterator over keys of this object

Instruction: obj.names();
Page: https://developer.android.com/reference/org/json/JSONObject
Context: obj a JSONObject
Returns: An arrays over keys of this object

Instruction: obj.opt(name);
Page: https://developer.android.com/reference/org/json/JSONObject
Context: obj a JSONObject
Returns: The Object designed by name in obj, or null if it does not exists

Instruction: obj.optTyp(name);
Page: https://developer.android.com/reference/org/json/JSONObject
Context: obj a JSONObject
name a string
typ a Type
Returns: The Object designed by name in obj, if it existst and can be coerced to type Typ. Or null if it does not exists

Instruction: obj.put(
  name,
  val
);
Page: https://developer.android.com/reference/org/json/JSONObject
Effect: Adds the value val for name name in obj
Context: obj a JSONObject
name a string
val a value
Returns: obj
Assuming: val can be used in JSON

Instruction: obj.putObj(
  name,
  val
);
Page: https://developer.android.com/reference/org/json/JSONObject
Effect: Adds the value val for name name in obj if both name and val are not Null. DOes nothing otherwise
Returns: obj
Variables: obj a JSONObject
name a string
val a value
Assuming: val can be used in JSON

Instruction: obj.remove(name);
Page: https://developer.android.com/reference/org/json/JSONObject
Effect: Remove value name from obj if it exists, does nothing otherwise
Context: obj a JSONObject
name a string
Returns: obj

Instruction: obj.toJSONArray(names);
Page: https://developer.android.com/reference/org/json/JSONObject
Context: obj a JSONObject
names a jsonArray
Returns: The JSONArray of values designated by name in names

Instruction: obj.toString();
Page: https://developer.android.com/reference/org/json/JSONObject
Context: obj a JSONObject
Returns: The json string representing this object

Instruction: json.toString(indentSpace);
Page: https://developer.android.com/reference/org/json/JSONObject
Context: json a JSONObject/array
Returns: The json string representing this object  with indentSpace for each substring

Instruction: JSONObject.numberToString(n)
Page: https://developer.android.com/reference/org/json/JSONObject
Context: json a JSON object/array
n a number
Returns: A string representing n as in JSON

Instruction: JSONObject.quote(data)
Page: https://developer.android.com/reference/org/json/JSONObject
Context: data : String
Returns: data as a JSON string. This applies quotes and any necessary character escaping.

Instruction: JSONObject.wrap(o)
Page: https://developer.android.com/reference/org/json/JSONObject
Context: o: Object
Returns: An JSONValue similar to o

Instruction: JSONArray()
Page: https://developer.android.com/reference/org/json/JSONArray.html
Returns: An empty JSON Array

Instruction: JSONArray(copyFrom)
Page: https://developer.android.com/reference/org/json/JSONArray.html
Returns: JSONArray with the values of copyFrom
Variables: copyFrom: collection or array
Assuming: Values of the collection are supported

Instruction: JSONArray(json)
Page: https://developer.android.com/reference/org/json/JSONArray.html
Returns: JSONArray encoded by the string json
Variables: json: aString
Assuming: Values of the collection are supported

Instruction: ar.get(index)
Page: https://developer.android.com/reference/org/json/JSONArray.html
Returns: Object at index index
Variables: ar: JSONArrayindex: int
Exception: JSONException if there is no value at this index, or if it's null

Instruction: ar.getType(index)
Page: https://developer.android.com/reference/org/json/JSONArray.html
Returns: Value of type Typ at index index
Variables: ar: JSONArrayindex: int
typ a Type
Exception: JSONException in case of wrong index, or values which can't be coerced to typ

Instruction: isNull(index)
Page: https://developer.android.com/reference/org/json/JSONArray.html
Returns: Whether there is no value at position index or it's null or Null
Variables: index: int
typ a Type

Instruction: ar.join(separator)
Page: https://developer.android.com/reference/org/json/JSONArray.html
Returns: String, containing each element, separated by separator
Variables: ar a JSONArray
separator: String

Instruction: ar.length()
Page: https://developer.android.com/reference/org/json/JSONArray.html
Returns: Number of elements in the array
Variables: ar a JSONArray

Instruction: ar.opt(index)
Page: https://developer.android.com/reference/org/json/JSONArray.html
Returns: Object at position index if it exists, null otherwise
Variables: ar a JSONArray
index: int

Instruction: ar.optTyp(index)
Page: https://developer.android.com/reference/org/json/JSONArray.html
Returns: Object at position index if it exists and can be coerced to type Typ, null otherwise
Variables: ar a JSONArray
index: int
typ: Type

Instruction: ar.put(val)
Page: https://developer.android.com/reference/org/json/JSONArray.html
Effect: Add value at the end of the array
Returns: ar
Variables: ar a JSONArray
val some value

Instruction: ar.put(
  index,
  val
)
Page: https://developer.android.com/reference/org/json/JSONArray.html
Effect: Add value at position index. Add null value between last position and index
Returns: ar
Variables: ar a JSONArray
index int
val some value

Instruction: ar.remove(index)
Page: https://developer.android.com/reference/org/json/JSONArray.html
Effect: Remove value at position index if it exists
Returns: Value at position index or null if it does not exists
Variables: ar a JSONArray
index int

Instruction: ar.toJSONObject(names)
Page: https://developer.android.com/reference/org/json/JSONArray.html
Returns: Null if one array is empty.
otherwise a json object sending i-th name to i-th value of Ar. Limiting to the smallest of the array
Variables: ar a JSONArray
names: String

Instruction: new JSONTokener(json);
Page: https://developer.android.com/reference/org/json/JSONTokener
Returns: A tokener used to transform a JSON string into JSON values
Variables: json a String

Instruction: tokener.nextValue()
Page: https://developer.android.com/reference/org/json/JSONTokener
Returns: First valid json value from the string passed to the creator and not yet returned.
Variables: tokener : JSONTokener