Class JSONValue
- java.lang.Object
-
- com.github.tnakamot.json.value.JSONValue
-
- Direct Known Subclasses:
JSONValuePrimitive
,JSONValueStructured
public abstract class JSONValue extends Object
Represents one JSON value.Instances of this class are immutable.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description @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.@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.abstract @NotNull String
toTokenString()
Convert this JSON value toString
which can be saved as a JSON text to a file or transmitted to network.abstract @NotNull String
toTokenString(String newline, String indent)
Convert this JSON value toString
which can be saved as a JSON text to a file or transmitted to network.@NotNull JSONValueType
type()
Type of this JSON value.
-
-
-
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 toString
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 toString
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
-
-