stringifyJson #
Checks that a value can be written as JSON and returns its JSON text.
Usage #
TypeScript
import { stringifyJson } from 'kawapress'
const json = stringifyJson({ title: 'Hi' })Parameters
valueunknown
The value to write.
optionsoptionalJsonOperationOptions
Names used in the error message.
default {}
labeloptionalstring
What the value is, named in the error message, for example page data.
pathoptionalstring
Where the value sits, named in the error message, for example pageData.headers.
Returns The JSON text, safe to place inside a <script> tag.
Full type signature
TypeScript
function stringifyJson(value: unknown, options?: JsonOperationOptions): string

Comments