Simdjsont.Encode

simdjsont · API reference

Encoding using a codec.

The output is compact JSON with no extra whitespace. For zero-copy output to another parser, use to_bigstring; for ordinary APIs or logs, use to_string.

let json = Simdjsont.Encode.to_string user_codec user
val to_string : 'a Codec.t -> 'a -> string

to_string codec v encodes v using codec and returns a JSON string.

val to_buffer : 'a Codec.t -> 'a -> Buffer.t

to_buffer codec v encodes v using codec and returns a fresh buffer containing the JSON representation.

val to_bigstring : 'a Codec.t -> 'a -> Raw.buffer * int

to_bigstring codec v encodes v directly into a parse-ready bigstring, returning it with the number of valid bytes. The result can be fed straight back into decode_bigstring without a copy.