This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

at main 1.8 kB View raw
1(*--------------------------------------------------------------------------- 2 Copyright (c) 2025 Anil Madhavapeddy. All rights reserved. 3 SPDX-License-Identifier: ISC 4 ---------------------------------------------------------------------------*) 5 6(** JSON object-as-map codec utilities. 7 8 JMAP frequently uses JSON objects as maps with string or Id keys. 9 These codecs convert between JSON objects and OCaml association lists. 10 11 @canonical Jmap.Proto.Json_map *) 12 13val of_string : 'a Jsont.t -> (string * 'a) list Jsont.t 14(** [of_string value_jsont] creates a codec for JSON objects 15 used as string-keyed maps. Returns an association list. 16 17 {[ 18 { "en": "Hello", "fr": "Bonjour" } 19 (* decodes to: [("en", "Hello"); ("fr", "Bonjour")] *) 20 ]} *) 21 22val of_id : 'a Jsont.t -> (Proto_id.t * 'a) list Jsont.t 23(** [of_id value_jsont] creates a codec for JSON objects 24 keyed by JMAP identifiers. Keys are validated as JMAP Ids. 25 26 {[ 27 { "Mdc123": { ... }, "Mdc456": { ... } } 28 (* decodes to: [(id1, obj1); (id2, obj2)] *) 29 ]} *) 30 31val id_to_bool : (Proto_id.t * bool) list Jsont.t 32(** Codec for [Id[Boolean]] maps, common in JMAP (e.g., mailboxIds, keywords). 33 34 {[ 35 { "Mbox1": true, "Mbox2": true } 36 (* decodes to: [(mbox1_id, true); (mbox2_id, true)] *) 37 ]} *) 38 39val string_to_bool : (string * bool) list Jsont.t 40(** Codec for [String[Boolean]] maps. 41 42 {[ 43 { "$seen": true, "$flagged": true } 44 (* decodes to: [("$seen", true); ("$flagged", true)] *) 45 ]} *) 46 47val null_safe_list : 'a Jsont.t -> 'a list Jsont.t 48(** [null_safe_list inner] decodes [null] as empty list, array as list. 49 Useful for fields that may be null or array per RFC 8621. 50 51 {[ 52 null (* decodes to: [] *) 53 ["a", "b"] (* decodes to: ["a"; "b"] *) 54 ]} *)