Open triglav opened 4 months ago
A quick naive way to fix the problem:
SuperJSON.registerCustom<Float64Array, string>(
{
isApplicable: (v): v is Float64Array =>
Object.prototype.isPrototypeOf.call(Float64Array.prototype, v),
serialize: v => v.join(","),
deserialize: v => new Float64Array(v.split(",").map(e => +e)),
},
"Float64ArrayCustom"
);
try out my implementation @jsheaven/tjson https://github.com/jsheaven/tjson
Float64Array
accepts only numbers,null
is not a valid value for this type. UnfortunatellyNaN
values within the array are serialised asnull
, which then naturally comes back after deserialising as0
. This essentially results in data loss/corruption.Simple example to reproduce/observe the problem: