Class JSONValueString


  • public class JSONValueString
    extends JSONValuePrimitive
    Represents one JSON 'string' value.

    Instances of this class are immutable.

    • Constructor Detail

      • JSONValueString

        public JSONValueString​(String value)
        Create an instance of a Java representation of a JSON string value.
        Parameters:
        value - value represented by a Java String object of this JSON string value. Null is considered as an empty string.
      • JSONValueString

        public JSONValueString​(JSONTokenString token)
        Create an instance of a Java representation of a JSON string value from a JSON string token.
        Parameters:
        token - source token of this JSON string value.
    • Method Detail

      • value

        public String value()
        Return the value represented by a Java String object of this JSON string value.
        Returns:
        value represented by a Java String object of this JSON string value. Never be null.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • toTokenString

        @NotNull
        public @NotNull String toTokenString()
        Description copied from class: JSONValue
        Convert this JSON value to String which can be saved as a JSON text to a file or transmitted to network. The output text is optimized for machine, so no indent or new lines will be inserted.

        Note that, according to RFC 8259 - 8.1 Character Encoding, your application program must encode the returned String using UTF-8 without BOM before writing the returned String to a file or a network stream, or network datagram(s). It is caller's responsibility to correctly encode it.

        Specified by:
        toTokenString in class JSONValue
        Returns:
        a string representation of this JSON value
      • toTokenString

        @NotNull
        public @NotNull String toTokenString​(String newline,
                                             String indent)
        Description copied from class: JSONValue
        Convert this JSON value to String which can be saved as a JSON text to a file or transmitted to network. The output text is optimized for human. Indents and new line characters are inserted accordingly.

        Note that, according to RFC 8259 - 8.1 Character Encoding, your application program must encode the returned String using UTF-8 without BOM before writing the returned String to a file or a network stream, or network datagram(s). It is caller's responsibility to correctly encode it.

        Specified by:
        toTokenString in class JSONValue
        Parameters:
        newline - line separator; "\r", "\n" or "\r\n"
        indent - indent string. Must consist of " " and "\t".
        Returns:
        a string representation of this JSON value