Json
constJson:object
Defined in: Data/Json.ts:23
Pure, non-throwing JSON utilities.
Wraps runtime JSON parsing and stringifying in typed Result containers.
Type Declaration
Section titled “Type Declaration”parse: <
T>(text) =>Result<SyntaxError,T>
Safely parses a JSON string into unknown (or a designated type T).
Converts thrown exceptions into a Result<SyntaxError, T>.
Type Parameters
Section titled “Type Parameters”T = unknown
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Result<SyntaxError, T>
Example
Section titled “Example”stringify
Section titled “stringify”stringify: (
value,replacer?,space?) =>Result<TypeError,string>
Safely stringifies a value into a JSON string.
Converts thrown exceptions (e.g. circular references) or un-serializable values (e.g. undefined, functions) into a Result<TypeError, string>.
Parameters
Section titled “Parameters”unknown
replacer?
Section titled “replacer?”(this, key, value) => any
space?
Section titled “space?”string | number
Returns
Section titled “Returns”Result<TypeError, string>