Package ch.epfl.cs107.play.data.json
Class JSONObject
java.lang.Object
ch.epfl.cs107.play.data.json.JSONValue
ch.epfl.cs107.play.data.json.JSONObject
Used to represent json objects
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds a value to this objectbooleancontainsKey(String key) Returns whether this object contains the given keyget()Returns all the values in this objectReturns the value with the given keykeySet()Returns the set of keys in this objectprotected static JSONObjectParses a list of lines into a JSONObjectRemoves the value with the given keyprotected StringSerializes the implementing class to a JSON-formatted string.
-
Constructor Details
-
JSONObject
public JSONObject()
-
-
Method Details
-
add
Adds a value to this object- Parameters:
key- (String): The key of the value to addvalue- (JSONValue): The value to add- Returns:
- (JSONObject): This object
-
get
Returns all the values in this object- Returns:
- The value of this object
-
get
Returns the value with the given key- Parameters:
key- (String): The key of the value to return- Returns:
- (JSONValue): The value with the given key
-
containsKey
Returns whether this object contains the given key- Parameters:
key- (String): The key to check- Returns:
- (boolean): Whether this object contains the given key
-
remove
Removes the value with the given key- Parameters:
key- (String): The key of the value to remove- Returns:
- (JSONObject): This object
-
keySet
Returns the set of keys in this object- Returns:
- The set of keys in this object
-
toJSONString
Description copied from class:JSONValueSerializes the implementing class to a JSON-formatted string.- Specified by:
toJSONStringin classJSONValue- Returns:
- A JSON-formatted string representation of the object.
-
parse
Parses a list of lines into a JSONObject- Parameters:
lines- The lines to parse- Returns:
- (JSONObject): The parsed JSONObject
-