Commits

Dmitry Grebeniuk  committed c46326a

Cd_Json: + [de]ser common mechanism

  • Participants
  • Parent commits 9581445

Comments (0)

Files changed (1)

File src/cd_Json.ml

      in
        ( uti_add_meth ti "json.to" u_json_to_meth
        ; uti_add_meth ti "json.from" u_json_from_meth
+       ; Cd_Ser.ti_gen_add_ser ti "json"
+           (fun a ->
+              let j = json_to a
+              and b = Buffer.create 80 in
+              let () = Json_io.Fast.print
+                ~recursive:True ~allow_nan:True b j in
+              Buffer.contents b
+           )
+       ; Cd_Ser.ti_gen_add_deser ti "json"
+           (json_from %<
+            Json_io.json_of_string
+              ~allow_comments:True
+              ~allow_nan:True
+              ~big_int_mode:True
+              ~recursive:True
+           )
        )
    ;