adam@5: (** The JSON text-based serialization format *) adam@5: adam@0: class json adam@0: adam@0: val toJson : a ::: Type -> json a -> a -> string adam@0: val fromJson : a ::: Type -> json a -> string -> a ezyang@23: val fromJson' : a ::: Type -> json a -> string -> a * string adam@0: adam@0: val mkJson : a ::: Type -> {ToJson : a -> string, adam@0: FromJson : string -> a * string} -> json a adam@0: adam@0: val json_string : json string adam@0: val json_int : json int adam@0: val json_float : json float adam@0: val json_bool : json bool adam@4: val json_option : a ::: Type -> json a -> json (option a) adam@0: val json_list : a ::: Type -> json a -> json (list a) adam@1: adam@1: val json_record : ts ::: {Type} -> folder ts -> $(map json ts) -> $(map (fn _ => string) ts) -> json $ts ezyang@22: val json_variant : ts ::: {Type} -> folder ts -> $(map json ts) -> $(map (fn _ => string) ts) -> json (variant ts) ezyang@22: ezyang@22: val json_unit : json unit ezyang@23: ezyang@23: functor Recursive (M : sig ezyang@23: con t :: Type -> Type ezyang@23: val json_t : a ::: Type -> json a -> json (t a) ezyang@23: end) : sig ezyang@23: datatype r = Rec of M.t r ezyang@23: ezyang@23: val json_r : json r ezyang@23: end