Interface: StringifyOptions

json.StringifyOptions

Options for the stringify function

Hierarchy

Table of contents

Properties

Properties

indentation

Optional indentation: string | number

The indentation to give each nested level of node

If a string is passed, that string is used as indentation. If a number higher than zero is passed, the indentation is set to the whitespace character repeated for that number of times. If zero is passed or no indentation is given, no newlines with indentation will be inserted into the output.

Defined in

src/json.d.ts:256


replaceJsonValue

Optional replaceJsonValue: (key: string | number, value: unknown, originalValue: unknown) => unknown

Replacer function called for every JSON value in the data being transformed

The replacer can return any JSON value, which will be used instead of the original value. If undefined is returned, the value will be discarded.

If the originalValue had a toJSON method, it will be called and the result will be the value parameter. In all other cases value and originalValue will be the same value.

Param

The name of the property or the index inside an array

Param

The value being handled

Param

The original value

Type declaration

▸ (key, value, originalValue): unknown

Replacer function called for every JSON value in the data being transformed

The replacer can return any JSON value, which will be used instead of the original value. If undefined is returned, the value will be discarded.

If the originalValue had a toJSON method, it will be called and the result will be the value parameter. In all other cases value and originalValue will be the same value.

Parameters
NameTypeDescription
keystring | numberThe name of the property or the index inside an array
valueunknownThe value being handled
originalValueunknownThe original value
Returns

unknown

Defined in

src/json.d.ts:272


replaceKdlValue

Optional replaceKdlValue: (key: string | number, value: Entry | Node, jsonValue: unknown, originalJsonValue: unknown) => undefined | Entry | Node

Replacer function called for every KDL node or entry created

The replacer can return an entry or node. If an entry is returned but an entry would not be valid in the given location, it will be transformed into a node. If undefined is returned, the value will be discarded.

Param

The name of the property or the index inside an array

Param

The entry or node that was created

Param

The JSON value that was transformed into the KDL value

Param

Type declaration

▸ (key, value, jsonValue, originalJsonValue): undefined | Entry | Node

Replacer function called for every KDL node or entry created

The replacer can return an entry or node. If an entry is returned but an entry would not be valid in the given location, it will be transformed into a node. If undefined is returned, the value will be discarded.

Parameters
NameTypeDescription
keystring | numberThe name of the property or the index inside an array
valueEntry | NodeThe entry or node that was created
jsonValueunknownThe JSON value that was transformed into the KDL value
originalJsonValueunknown
Returns

undefined | Entry | Node

Defined in

src/json.d.ts:290