Json
Type of JSON values, and its functions.
Type of JSON values.
JSON numbers are stored as BigDecimal for lossless round-trip;
JSON objects are stored as Map[String, Json], which gives
canonical (sorted) key order on output.
Instances
Traits
| FromJson | Trait for types that can be decoded from a `Json` value. |
| ToJson | Trait for types that can be encoded as a `Json` value. |
Enums
| JsonError | Type of JSON parsing and decoding errors. |
| JsonPath | Type of paths locating values inside a `Json` document. |
Definitions
Parses s as a JSON value and decodes it as a via FromJson[a].
Returns Err(Parse(...)) if parsing fails or Err(Decode(...)) if
decoding fails.
Parses s as a JSON value.
Returns Ok(j) if s is a single well-formed JSON value (with
optional surrounding whitespace) and nothing else. Returns
Err(JsonError) otherwise — see Json.JsonError for the cases.
Returns the compact JSON rendering of j: a single line with
no extraneous whitespace.
Returns the pretty-printed JSON rendering of j, using indent spaces
per nesting level.
Empty arrays and objects are rendered on a single line as [] or {}.
Non-empty containers place each element on its own line; object keys
are followed by ": ".
def toRichString(indent: Int32, j: Json): RichString§ SourceReturns the pretty-printed JSON rendering of j as a RichString,
with syntax-coloured tokens.
The layout is identical to toPrettyString. Colours: null is gray,
booleans are magenta, numbers are yellow, string values are green,
and object keys are cyan. Punctuation and whitespace use the default
colour.