Something went wrong. Try again.
SQL frontend over the catalog engine
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647(*--------------------------------------------------------------------------- Copyright (c) 2026 Thomas Gazagnaire. All rights reserved. SPDX-License-Identifier: ISC ---------------------------------------------------------------------------*)
(** JSON text to JSONB and back, as sqlite/src/json.c 3.54.1 writes them. Internal to sql: {!Sql.Json} and the json1 functions read and write text through it. *)
val of_string : string -> (Jsonb_core.t, int) result(** [of_string z] is the JSONB of the JSON or JSON5 text [z], its [has_nonstd] set if [z] needed JSON5, or [Error i] if [z] is neither, [i] the byte offset where the parser stopped (jsonConvertTextToBlob and its iErr). *)
val blob_of_text : string -> string(** [blob_of_text z] is the JSONB of the RFC 8259 text [z] the json1 functions wrote (jsonReturnStringAsBlob). *)
(** {1 Rendering} *)
type out = { b : Buffer.t; mutable bad : bool; mutable deep : bool }(** The type for text being rendered: the text, whether the JSONB it renders is malformed, and whether it nests too deep. *)
val out : unit -> out(** [out ()] is an empty rendering. *)
val add_string : Buffer.t -> string -> int -> int -> unit(** [add_string b s off len] adds [len] bytes of [s] from [off] as a JSON string (jsonAppendString). *)
val render : Jsonb_core.t -> int -> out -> int(** [render t i o] adds the element at [i] to [o] as RFC 8259 text and is the offset past it. *)
val text_at : Jsonb_core.t -> int -> string(** [text_at t i] is the element at [i] as RFC 8259 text.
@raise Catalog.Error if it is malformed or nests too deep. *)
val pretty : Jsonb_core.t -> indent:string -> string(** [pretty t ~indent] is the root of [t] as RFC 8259 text, an array's elements and an object's members one to a line, each [indent] once per level (jsonTranslateBlobToPrettyText).
@raise Catalog.Error if it is malformed or nests too deep. *)