to_string
Convert a piece of data to string
Definition
string to_string(any $arg)
Returns the JSON encoded value of $arg
, i.e., the way that $arg
is represented in the JSON file.
Parameters
any $arg
A piece of data of any type.
Returns
string
The string representing $arg
inside a JSON file.
Examples
{
a: to_string(`null`),
b: to_string(`1`),
c: to_string('text'),
d: to_string(`{name: 'Jane'}`),
e: to_string(`[]`),
f: to_string(`[1, 2, 3]`)
}
{
"a": "null",
"b": "1",
"c": "text",
"d": "{\"name\":\"Jane\"}", // The backslash is used to escape apostrophes
"e": "[]",
"f": "[1,2,3]"
}
Updated about 1 year ago