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.
Input and output properties are shown below.
||*||Required. Any valid JSON value to convert to a JSON string.|
||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.|
||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.|
||String||A JSON string representing the given
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.
In this example, the
replacer values are
In this example, all properties of the object are included in the resulting JSON string.