Package ch.epfl.cs107.play.data.json
Class JSONString
java.lang.Object
ch.epfl.cs107.play.data.json.JSONValue
ch.epfl.cs107.play.data.json.JSONString
Used to represent json strings, ints, doubles and booleans
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of this objectReturns the value of this objectgetInt()Returns the value of this objectReturns the value of this objectstatic booleanChecks if the given string is a booleanstatic booleanChecks if the given string is a doublestatic booleanChecks if the given string is an integervoidSets the value of this objectprotected StringSerializes the implementing class to a JSON-formatted string.
-
Constructor Details
-
JSONString
Creates a new JSONString with the given value- Parameters:
value- (String): The value of the string
-
-
Method Details
-
set
Sets the value of this object- Parameters:
value- (String): The new value of this object
-
getString
Returns the value of this object- Returns:
- (String): The value of this object as a String
-
getInt
Returns the value of this object- Returns:
- (Integer): The value of this object as an Integer
-
getDouble
Returns the value of this object- Returns:
- (Double): The value of this object as a Double
-
getBoolean
Returns the value of this object- Returns:
- (Boolean): The value of this object as a Boolean
-
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.
-
isInteger
Checks if the given string is an integer- Parameters:
str- (String): The string to check- Returns:
- (boolean): True if the string is an integer, false otherwise
-
isBoolean
Checks if the given string is a boolean- Parameters:
str- (String): The string to check- Returns:
- (boolean): True if the string is a boolean, false otherwise
-
isDouble
Checks if the given string is a double- Parameters:
str- (String): The string to check- Returns:
- (boolean): True if the string is a double, false otherwise
-