UNPKG

@stryke/json

Version:

A package containing JSON parsing/stringify utilities used by Storm Software.

17 lines 1.12 kB
//#region src/canonical.d.ts /** * Converts a JavaScript value to a canonical JSON string representation. This function is used for signing JSON objects in a consistent way, ensuring that the same input will always produce the same output string. The canonicalization process includes: * - Sorting object keys in lexicographical order. * - Removing whitespace and line breaks. * - Representing primitive values (null, boolean, number, string) in their standard JSON format. * - Recursively applying these rules to nested objects and arrays. * * This function is designed to produce a deterministic string representation of a JSON value, which is essential for cryptographic signing and verification processes where the exact byte representation of the data must be consistent across different environments and implementations. * * @param obj - The JavaScript value to convert to a canonical JSON string. * @returns A canonical JSON string representation of the input value. */ declare function canonicalJson(obj: unknown): string; //#endregion export { canonicalJson }; //# sourceMappingURL=canonical.d.cts.map