to_string

Modified on Thu, 9 Jul at 10:50 AM

to_string

TABLE OF CONTENTS

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

Transformation
{
  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]`)
}
Result
{
  "a": "null",
  "b": "1",
  "c": "text",
  "d": "{\"name\":\"Jane\"}",    // The backslash is used to escape apostrophes
  "e": "[]",
  "f": "[1,2,3]"
}

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article