objectToString
  • 18 Oct 2024
  • Dark
    Light
  • PDF

objectToString

  • Dark
    Light
  • PDF

Article summary

objectToString Task Purpose

The objectToString task is used to convert any valid JSON value to a JSON string. In contrast to parse, this task method returns a string representation of a JSON value.

Potential Use Cases

You could use objectToString as a formatting method to display content that is readable in a web browser. This task could also be used for logging or any other circumstance where you need to render a JSON object contextually as a string in a readable format.

Properties

Input and output properties are shown below.

Input Type Description
value * Required. Any valid JSON value to convert to a JSON string.
replacer Array Optional. An array of string and number objects that serve as an allowlist (whitelist) for selecting/filtering the properties of the value object to be included in the JSON string. If this value is not provided, all properties of the object are included in the resulting JSON string.
space Number Optional. A number from 0 to 10 to indicate how many whitespaces (or space characters) to insert in the output JSON string. This parameter is used for readability purposes to control spacing in the final string.


Output Type Description
stringified String A JSON string representing the given value.

Example 1

In the example shown below, the incoming value is statically set. The replacer value (filtering property) is "city", and the number of space characters to insert is 2.

objectToString-01

objectToString-02

Example 2

In this example, the replacer values are "age" and "city".

objectToString-03

objectToString-04

Example 3

In this example, all properties of the object are included in the resulting JSON string.

objectToString-05

objectToString-06


Was this article helpful?

What's Next
Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.