rescript-core icon indicating copy to clipboard operation
rescript-core copied to clipboard

JSON.Classify can't classify bigints

Open tx46 opened this issue 2 months ago • 0 comments

there's no type-safe way to serialize them because of this i think:

  let stringifySafe = v =>
    JSON.stringifyAnyWithReplacer(v, (k, v) =>
      switch typeof(v) {
      | #bigint =>
        let bi = (Obj.magic(v) :> BigInt.t)
        JSON.Encode.string(bi->BigInt.toString ++ "n")
      | _ => v
      }
    )

fix: add BigInt to JSON.Classify? (i recall support for @unboxed BigInt.t being added rather recently)

tx46 avatar Oct 14 '25 03:10 tx46