var stringify =require('fast-json-stable-stringify')
var str = stringify(obj, opts)
Return a deterministic stringified string str from the object obj.
options
cmp
If opts is given, you can supply an opts.cmp to have a custom comparison function for object keys. Your function opts.cmp is called with these parameters:
For example, to sort on the object key names in reverse order you could write:
which results in the output string:
Or if you wanted to sort on the object values in reverse order, you could write:
which outputs:
cycles
Pass true in opts.cycles to stringify circular property as __cycle__ - the result will not be a valid JSON string in this case.
TypeError will be thrown in case of circular object without this option.