Tomlt_jsontJsont codecs for TOML tagged JSON format.
This module provides bidirectional codecs between TOML values and the tagged JSON format used by toml-test.
The toml-test suite uses a "tagged JSON" format where each TOML value is represented as a JSON object with type information:
{"type": "string", "value": "hello"}[tagged_value, ...]{"key": tagged_value, ...}Using the native encoder (recommended for compatibility):
let json = Tomlt_jsont.encode toml_value let toml = Tomlt_jsont.decode json_string
Using jsont codecs (for integration with jsont pipelines):
let json = Tomlt_jsont.encode_jsont toml_value let toml = Tomlt_jsont.decode_jsont json_string
module Toml = Tomlt.TomlRe-exported TOML module for convenience.
These functions use Tomlt's built-in tagged JSON encoder/decoder, which is highly optimized for the toml-test format.
val encode : Toml.t -> stringencode v encodes TOML value v to tagged JSON format. This uses Toml.Tagged_json.encode directly.
val decode : string -> Toml.tdecode s decodes tagged JSON string s to a TOML value. This uses Toml.Tagged_json.decode directly.
decode_result s is like decode but returns a result.
The toml codec provides a jsont-based implementation of the tagged JSON format. This allows integration with jsont pipelines and other jsont-based tooling.
toml is a jsont codec for TOML values in tagged JSON format.
This codec can decode and encode the tagged JSON format used by toml-test. On decode, it distinguishes between:
{"type": "T", "value": "V"} (exactly these two keys)On encode, TOML values are converted to appropriate tagged JSON.
These functions use the jsont codec with Jsont_bytesrw for string-based encoding/decoding.
encode_jsont v encodes TOML value v using the jsont codec. Returns an error string on failure.
decode_jsont s decodes tagged JSON s using the jsont codec. Returns an error string on failure.
val decode_jsont' : string -> (Toml.t, Jsont.Error.t) resultdecode_jsont' s is like decode_jsont but preserves the error.
val decode_jsont_exn : string -> Toml.tdecode_jsont_exn s is like decode_jsont' but raises on error.
These are exposed for advanced use cases but may change between versions.
A tagged scalar value with type and value strings.
val tagged_jsont : tagged_value Jsont.tJsont codec for tagged scalar values.
val tagged_to_toml : tagged_value -> Toml.tConvert a tagged value to its TOML representation.
val toml_to_tagged : Toml.t -> tagged_valueConvert a TOML scalar to a tagged value.