While the default parser of Decoverto is the builtin JSON object, it is possible to customize and overwrite it.
The parser can be specified when creating a new instance of Decoverto. Example:
import {Decoverto} from 'decoverto';
import customParser from 'custom-parser';
const decoverto = new Decoverto({
parser: {
parse: customParser.parse,
toRaw: customParser.toBinary,
},
})
If you want to use a custom indent size, replacer, or reviver, the JsonParser
class can be used.
The options of JsonParser
match the arguments of
JSON.parse()
and
JSON.stringify()
.
All options are optional.
Example:
import {Decoverto, JsonParser} from 'decoverto';
const decoverto = new Decoverto({
parser: new JsonParser({
replacer: replacerFn,
reviver: reviverFn,
spaces: 4,
}),
});