In preparation to adding support for bigints (cf. #1679), I add a few mock datasets with bigint literals and I implement an opt-in way to enable big int serialization for the Raw visualization and metadata viewer in consumer apps.
For JSON.stringify() to support bigint, one has to implement BigInt.prototype.toJSON. I really don't want to do this in @h5web/app or @h5web/lib because extending built-in objects is dangerous. If H5Web is integrated into an app that already implements its own JSON serialization, H5Web could unknowingly break this parent app. That's why I think it's safer to give this responsibility to the consumer app.
Since the goal is for providers to return bigint values/typed arrays if possible, and since there will always be cases where bigints need to be serialized for display (attributes, nested compounds, etc.), this should at least provide a much more robust and future-proof solution for #1536.
In preparation to adding support for bigints (cf. #1679), I add a few mock datasets with
bigint
literals and I implement an opt-in way to enable big int serialization for the Raw visualization and metadata viewer in consumer apps.For
JSON.stringify()
to support bigint, one has to implementBigInt.prototype.toJSON
. I really don't want to do this in@h5web/app
or@h5web/lib
because extending built-in objects is dangerous. If H5Web is integrated into an app that already implements its own JSON serialization, H5Web could unknowingly break this parent app. That's why I think it's safer to give this responsibility to the consumer app.Since the goal is for providers to return bigint values/typed arrays if possible, and since there will always be cases where bigints need to be serialized for display (attributes, nested compounds, etc.), this should at least provide a much more robust and future-proof solution for #1536.