Determines how to handle bigints. Can be set to either:
BigintFormatType.Number
: uses 'json-bigint to safely serialize,BigintFormatType.String
: converts bigint
to stringsBigintFormatType.None
: must be taken care of manually, e.g. in replacer function.
Defaults to BigintFormatType.NoneOptional
replacer: ReplacerFunA function that transforms the results.
This overrides bigintFormat
, and will also run on primitive values passed as value.
Optional
space: string | numberAdds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
Generated using TypeDoc
Stringify, which ensures concordium domain types are unwrapped to their inner type before stringified. This should be used if you want to manually deserialize the inner property values, as the serialization is irreversible.
Deprecated
Manually convert the object to the preferred JSON structure instead. For account transactions, use
AccountTransactionHandler.toJSON
prior to invokingJSON.stringify
. It's up to the developer to handle serialization ofbigints
, e.g. with thejson-bigint
dependency.Example
jsonUnwrapStringify(100n) => throws
TypeError
, as bigints cannot be serialized. jsonUnwrapStringify(100n, BigintFormatType.None) => throwsTypeError
jsonUnwrapStringify(100n, BigintFormatType.None, (_key, value) => 'replaced') => '"replaced"'jsonUnwrapStringify(100n, BigintFormatType.Number) => '100' jsonUnwrapStringify(100n, BigintFormatType.Number, (_key, value) => -value) => '-100' // runs both replacer and bigintFormat jsonUnwrapStringify(100n, BigintFormatType.Number, (_key, value) => 'replaced') => '"replaced"' // replacer takes precedence
jsonUnwrapStringify(100n, BigintFormatType.String) => '"100"' jsonUnwrapStringify(100n, BigintFormatType.String, (_key, value) => -value) => '"-100"' // runs both replacer and bigintFormat jsonUnwrapStringify(100n, BigintFormatType.String, (_key, value) => 10) => '10' // replacer takes precedence