Crdt.Op_codec
crdt · API reference
JSON codec for operations (verbose format)
JSON codec for CRDT operations.
Encodes/decodes operations in the json-joy verbose JSON format.
module J = Simdjsont.JsonTimestamp Codec
val encode_timestamp : Clock.timestamp -> J.tEncode a timestamp as sid, time JSON array
val decode_timestamp : J.t -> Clock.timestamp optionDecode a timestamp from JSON
Timespan Codec
val encode_timespan : Clock.timespan -> J.tEncode a timespan as sid, time, span JSON array
val decode_timespan : J.t -> Clock.timespan optionDecode a timespan from JSON
Object Entry Codec
val encode_obj_entry : Op.obj_entry -> J.tEncode an object entry as "key", [sid, time]
val decode_obj_entry : J.t -> Op.obj_entry optionDecode an object entry from "key", [sid, time]
Value Codec for new_con
val encode_con_value : Value.t -> J.tEncode a Value.t for new_con (only primitives: null, bool, number, string)
val decode_con_value : J.t -> Value.tDecode a Value.t from JSON for new_con
Operation Encoding
val make_obj : (string * J.t) list -> J.tMake a JSON object with the given members
val encode_op : Op.op_data -> J.tEncode an operation to JSON (verbose format)
Operation Decoding
val get_member : string -> (string * J.t) list -> J.t optionGet a member from a JSON object members list
val get_string : string -> (string * J.t) list -> string optionGet a string field from a JSON object
val get_timestamp : string -> (string * J.t) list -> Clock.timestamp optionGet a timestamp field from a JSON object
val get_int : string -> (string * J.t) list -> int optionGet an int field from a JSON object
val decode_op : J.t -> (Op.op_data, string) resultDecode an operation from JSON (verbose format)
String Encoding/Decoding
val encode : Op.op_data -> stringEncode an operation to a JSON string
val decode : string -> (Op.op_data, string) resultDecode an operation from a JSON string