api / tv.twelvetone.json / Json / parse

parse

fun parse(string: String): JsonValue

Parses the given input string as JSON. The input must contain a valid JSON value, optionally padded with whitespace.

Parameters

string - the input string, must be valid JSON

Exceptions

ParseException - if the input is not valid JSON

Return
a value that represents the parsed JSON

fun parse(reader: Reader): JsonValue

Reads the entire input from the given reader and parses it as JSON. The input must contain a valid JSON value, optionally padded with whitespace.

Characters are read in chunks into an input buffer. Hence, wrapping a reader in an additional BufferedReader likely won't improve reading performance.

Parameters

reader - the reader to read the JSON value from

Exceptions

IOException - if an I/O error occurs in the reader ParseException - if the input is not valid JSON

Return
a value that represents the parsed JSON