Class JSONValue

    • Method Detail

      • type

        @NotNull
        public @NotNull JSONValueType type()
        Type of this JSON value.
        Returns:
        type of this JSON value
      • toTokenString

        @NotNull
        public abstract @NotNull String toTokenString()
        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.

        Returns:
        a string representation of this JSON value
      • toTokenString

        @NotNull
        public abstract @NotNull String toTokenString​(String newline,
                                                      String indent)
        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.

        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
      • toTokenBytes

        @NotNull
        public @org.jetbrains.annotations.NotNull byte[] toTokenBytes()
        Convert this JSON value to a byte array 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.

        The returned byte array is encoded using UTF-8 without BOM in accordance with RFC 8259 - 8.1 Character Encoding.

        Returns:
        a byte array representation of this JSON value
      • toTokenBytes

        @NotNull
        public @org.jetbrains.annotations.NotNull byte[] toTokenBytes​(String newline,
                                                                      String indent)
        Convert this JSON value to a byte array 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.

        The returned byte array is encoded using UTF-8 without BOM in accordance with RFC 8259 - 8.1 Character Encoding.

        Parameters:
        newline - line separator; "\r", "\n" or "\r\n"
        indent - indent string. Must consist of " " and "\t".
        Returns:
        a byte array representation of this JSON value