(*--------------------------------------------------------------------------- Copyright (c) 2026 Thomas Gazagnaire. All rights reserved. SPDX-License-Identifier: ISC ---------------------------------------------------------------------------*) module Sort = Jsonb_sort module Error = Jsonb_error module Value = Jsonb_value module Codec = Jsonb_codec module Cursor = Jsonb_cursor type t = Value.t let pp = Value.pp type 'a codec = 'a Codec.t let sniff = Jsonb_core.is_jsonb let of_string_exn c s = let t = Jsonb_core.of_blob s in if Jsonb_core.validity t 0 (String.length s) 1 <> 0 then Error.fail_malformed (); Codec.dec_at c t 0 let of_string c s = match of_string_exn c s with | v -> Ok v | exception Catalog.Error e -> Error e let to_string = Codec.to_bytes let to_writer c v b = let t = Jsonb_core.empty 16 in Codec.enc_into c v t; Buffer.add_subbytes b t.a 0 t.n let decode_exn = Codec.decode let decode c v = match decode_exn c v with v -> Ok v | exception Catalog.Error e -> Error e let encode = Codec.encode