UNPKG

json-canonicalize

Version:
17 lines (15 loc) 624 B
import { _serialize } from './serializer'; /** * The main function for JSON canonicalization. It takes a JavaScript object and returns its canonical string representation. * * @param obj The JavaScript object to canonicalize. * @param allowCircular If `true`, the function will handle circular references in the object by replacing them with `null`. Defaults to `false`. * @returns The canonical string representation of the object. */ export function canonicalize(obj: any, allowCircular?: boolean) { return _serialize(obj, { allowCircular, filterUndefined: true, undefinedInArrayToNull: true, }); }