123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081(*
Mapping from ATD to JSON
*)typejson_float=[`Floatofintoption(* max decimal places *)|`Int]typejson_list=[`Array|`Object]typejson_variant={json_cons:stringoption}typejson_field={json_fname:string;(* <json name=...> *)json_tag_field:stringoption;(* <json tag_field=...> *)json_unwrapped:bool}typejson_repr=[|`Unit|`Bool|`Int|`Floatofjson_float|`String|`Sum|`Record|`Tuple|`Listofjson_list|`Option|`Nullable|`Wrap(* should we add support for Base64 encoding of binary data? *)|`External|`Cell|`Fieldofjson_field|`Variantofjson_variant|`Def]letjson_float_of_strings:[`Float|`Int]option=matchswith"float"->Some`Float|"int"->Some`Int|_->Noneletjson_precision_of_strings=trySome(Some(int_of_strings))with_->Noneletget_json_precisionan=Atd_annot.get_fieldjson_precision_of_stringNone["json"]"precision"anletget_json_floatan:json_float=matchAtd_annot.get_fieldjson_float_of_string`Float["json"]"repr"anwith`Float->`Float(get_json_precisionan)|`Int->`Intletjson_list_of_strings:json_listoption=matchswith"array"->Some`Array|"object"->Some`Object|_->Noneletget_json_listan=Atd_annot.get_fieldjson_list_of_string`Array["json"]"repr"anletget_json_consdefaultan=Atd_annot.get_field(funs->Somes)default["json"]"name"anletget_json_fnamedefaultan=Atd_annot.get_field(funs->Somes)default["json"]"name"anletget_json_tag_fieldan=Atd_annot.get_field(funs->Some(Somes))None["json"]"tag_field"anletget_json_untypedan=Atd_annot.get_flag["json"]"untyped"an