json-canonicalize
Version:
JSON canonicalize function
18 lines (16 loc) • 1.01 kB
text/typescript
import { ISerializeOptions, _serialize } from './serializer';
/**
* The extended canonicalization function, offering more granular control over the serialization process.
*
* @param obj The JavaScript object to canonicalize.
* @param options An object with the following properties:
* - `allowCircular` (boolean, optional): Same as in `canonicalize`.
* - `filterUndefined` (boolean, optional): If `true`, `undefined` values in objects will be filtered out. Defaults to `true`.
* - `undefinedInArrayToNull` (boolean, optional): If `true`, `undefined` values in arrays will be converted to `null`. Defaults to `true`.
* - `include` (string[], optional): An array of property names to include in the canonicalization.
* - `exclude` (string[], optional): An array of property names to exclude from the canonicalization.
* @returns The canonical string representation of the object.
*/
export function canonicalizeEx(obj: any, options?: ISerializeOptions) {
return _serialize(obj, options);
}