parseDocument

Parses a JSON string into a Document.

Empty or blank input yields an empty mutable document. Otherwise this delegates to toDocument which deserializes the provided JSON.

Return

a Document instance, never null

Parameters

json

JSON representation of a Document


fun parseDocument(source: Source): Document

Parses a Document by streaming JSON from a byte source.

Prefer this over parseDocument when the JSON originates as bytes (a file, a network response, a bundled resource): it decodes directly from the source and never materializes the whole document as an intermediate String, which matters for very large documents (e.g. collection fields with thousands of rows).

Return

a Document instance, never null

Parameters

source

byte source positioned at the start of a JSON document


Parses a Document from raw JSON bytes without decoding them to a String first.

Convenience wrapper around parseDocument for callers that already hold the bytes.

Return

a Document instance, never null

Parameters

bytes

UTF-8 encoded JSON representation of a Document