Package jsonvalues.spec
Class JsIO
java.lang.Object
jsonvalues.spec.JsIO
Singleton instance to create JSON readers and writers to parse bytes into JSON and serialize JSON into bytes. Only a
few a methods are exposed since this class is vastly used internally. You may be interested in creating JsReaders
only to parse bytes or strings token by token.
- See Also:
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionparseToJsArray
(byte[] bytes) Parses the given array of bytes into an immutable and persistent JSON array.parseToJsObj
(byte[] bytes) Parses the given array of bytes into an immutable and persistent JSON object.byte[]
Serializes the specified JSON into an array of bytesvoid
serialize
(Json<?> json, OutputStream stream) Serializes the specified JSON into the given output streamtoPrettyString
(Json<?> json, int indentLength) Serializes a JSON into a formatted string
-
Field Details
-
INSTANCE
Singleton instance
-
-
Method Details
-
parseToJsObj
Parses the given array of bytes into an immutable and persistent JSON object.- Parameters:
bytes
- the array of bytes- Returns:
- a JsObj object
- Throws:
JsParserException
- if the string doesn't represent a json object
-
parseToJsArray
Parses the given array of bytes into an immutable and persistent JSON array.- Parameters:
bytes
- the array of bytes- Returns:
- a JsArray object
- Throws:
JsParserException
- if the string doesn't represent a json object
-
serialize
Serializes the specified JSON into an array of bytes- Parameters:
json
- the JSON- Returns:
- an array of bytes
- Throws:
JsSerializerException
-
serialize
Serializes the specified JSON into the given output stream- Parameters:
json
- the JSONstream
- the stream- Throws:
JsSerializerException
-
toPrettyString
Serializes a JSON into a formatted string- Parameters:
json
- the jsonindentLength
- the indentation length- Returns:
- a string representation of the JSON
-