Safe, deterministic and fast serialization alternative to JSON.stringify.
MIT License
Published by BridgeAR almost 2 years ago
Published by BridgeAR about 2 years ago
string
, undefined
or string | undefined
depending on the input.Published by BridgeAR about 2 years ago
strict
option to verify that the passed in objects are fully compatible with JSON without removing information. If not, an error is thrown.Published by BridgeAR almost 3 years ago
Published by BridgeAR almost 3 years ago
Error
constructor as circularValue
option to throw on circular references as the regular JSON.stringify would:import { configure } from 'safe-stable-stringify'
const object = {}
object.circular = object;
const stringify = configure({ circularValue: TypeError })
stringify(object)
// TypeError: Converting circular structure to JSON
Published by BridgeAR almost 3 years ago
undefined
as circularValue
option to remove circular properties from the serialized output:import { configure } from 'safe-stable-stringify'
const object = { array: [] }
object.circular = object;
object.array.push(object)
configure({ circularValue: undefined })(object)
// '{"array":[null]}'
Published by BridgeAR about 3 years ago
maximumBreadth
option to limit stringification at a specific object or array "width" (number of properties / values)maximumDepth
option to limit stringification at a specific nesting depthPublished by BridgeAR about 3 years ago
bigint
option and set it to false
.Published by BridgeAR about 6 years ago
undefined
values (4196f87f16e95c711d1776102d6cc73f1c384431, 4eab558c2ddbf24adb5776e4fc1091aa8673b703)