Simdjsont.Validate

simdjsont · API reference

JSON validity checks.

Validation parses the input with simdjson but does not decode it into an OCaml value. Use is_valid for a boolean fast path and check when you want an error message.

match Simdjsont.Validate.check payload with
| Ok () -> handle_valid payload
| Error msg -> Printf.eprintf "invalid JSON: %s\n" msg
val is_valid : string -> bool

is_valid json returns true if json is valid JSON.

val check : string -> (unit, string) result

check json returns Ok () if json is valid JSON, otherwise Error msg.

val is_valid_bigstring : Raw.buffer -> len:int -> bool

is_valid_bigstring buf ~len is like is_valid for the first len bytes of a bigstring. Parsing is zero-copy when buf is already padded.

val check_bigstring : Raw.buffer -> len:int -> (unit, string) result

check_bigstring buf ~len is like check for a bigstring.