Class JSONTokenString


  • public class JSONTokenString
    extends JSONToken
    Represents one "string" type token in JSON text.

    A string token in a JSON text is surrounded by double quotations, and some special characters are unescaped. The method value() strips the surrounding double quotations, unescape the escaped characters and returns in accordance with RFC 8259 - 7. Strings.

    Instances of this class are immutable.

    • Constructor Detail

      • JSONTokenString

        public JSONTokenString​(String text,
                               String value,
                               StringLocation begin,
                               StringLocation end,
                               JSONText source)
        Creates one "string" type token of a JSON text.

        It is the caller's responsibility to validate the token text as string before creating this instance.

        Parameters:
        text - text of this token
        value - string value that this token represents (it is a caller's responsibility to parse the token text, strip surrounding double quotations and unescape escaped characters)
        begin - beginning location of this token within the source JSON text
        end - end location of this token within the source JSON text
        source - source JSON text where this token was extracted from
    • Method Detail

      • value

        public String value()
        Returns the string value of this token represents. All escapes characters in the original JSON text are unescaped.
        Returns:
        The string value of this token represents. Never be null.
        See Also:
        RFC 8259 - 7. Strings