Commits

camlspotter  committed 15b96b8

bug is found for json option converter

  • Participants
  • Parent commits 7161c53
  • Branches 4.01.0

Comments (0)

Files changed (2)

File json/json.ml

 type t =
   | String of string
-  | Number of float
+  | Number of float (* CR jfuruse: BUG: It cannot carry full int64 value. *)
   | Object of obj
   | Array of t list
   | Bool of bool

File json/json_conv.ml

 
 let json_of_int n       = Number (float n)
 let json_of_int32 n     = Number (Int32.to_float n)
-let json_of_int64 n     = Number (Int64.to_float n)
+let json_of_int64 n     = Number (Int64.to_float n) (* CR jfuruse: BUG: Int64.max_int cannot be mapped to float properly *)
 let json_of_nativeint n = Number (Nativeint.to_float n)
 let json_of_char c      = String (String.make 1 c)
 let json_of_string s    = String s
 let json_of_bool b      = Bool b
 let json_of_lazy_t f v  = f (Lazy.force v)
 let json_of_unit ()     = Null
+(* CR jfuruse: BUG: this makes [None] and [Some (None)] not distinguishable. i.e. t option^n are all mapped to t option *)
 let json_of_option f    = function
   | None -> Null
   | Some v -> f v
 let array_of_json f = 
   Helper.array_of (function Array xs -> Some xs | _ -> None) f
 
+(* CR jfuruse: BUG: Due to the inaccurate encoding of option, Some (Some (Some (Some x))) is encoded then decoded back to Some x *)
 let option_of_json f = Helper.option_of 
   (function Null -> Some None | v -> Some (Some v))
   f