json_dump

Converts a ThingsDB value in to a JSON string.

This function does not generate a change.

Function

json_dump(value, [options])

Arguments

Argument Type Description
value any The value to convert into a JSON string.
options thing Thing with options.

Options

Option Type Description
deep int Specify how deep the value must be converted. (defaults to the current deep value)
flags int Specify which flags to use; see return-flags
beautify bool Generate a JSON string with new lines and indentation to make the string more readable.

Return value

JSON string.

Example

This code shows an example for json_dump:

json_dump({
    success: true
});

Return value in JSON format

"{\"success\":true}"

Another example with extra options:

data = {
    people: [
        {name: 'Iris'},
        {name: 'Tess'},
    ]
};
json_dump(data, {deep: 2});

Return value in JSON format

"{\"people\":[{\"name\":\"Iris\"},{\"name\":\"Tess\"}]}"