Add support for reviver function. Fixes #6