Class JSONString

java.lang.Object
ch.epfl.cs107.play.data.json.JSONValue
ch.epfl.cs107.play.data.json.JSONString

public class JSONString extends JSONValue
Used to represent json strings, ints, doubles and booleans
  • Constructor Details

    • JSONString

      public JSONString(String value)
      Creates a new JSONString with the given value
      Parameters:
      value - (String): The value of the string
  • Method Details

    • set

      public void set(String value)
      Sets the value of this object
      Parameters:
      value - (String): The new value of this object
    • getString

      public String getString()
      Returns the value of this object
      Returns:
      (String): The value of this object as a String
    • getInt

      public Integer getInt()
      Returns the value of this object
      Returns:
      (Integer): The value of this object as an Integer
    • getDouble

      public Double getDouble()
      Returns the value of this object
      Returns:
      (Double): The value of this object as a Double
    • getBoolean

      public Boolean getBoolean()
      Returns the value of this object
      Returns:
      (Boolean): The value of this object as a Boolean
    • toJSONString

      protected String toJSONString()
      Description copied from class: JSONValue
      Serializes the implementing class to a JSON-formatted string.
      Specified by:
      toJSONString in class JSONValue
      Returns:
      A JSON-formatted string representation of the object.
    • isInteger

      public static boolean isInteger(String str)
      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

      public static boolean isBoolean(String str)
      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

      public static boolean isDouble(String str)
      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