objectToString

The objectToString task converts a valid JSON value to a JSON string, optionally replacing values with a replacer function, or optionally including only specified properties if a replacer array is provided.

Potential use case

Given a JSON object as input, this task returns a string containing all JSON object properties separated by commas. If a recent query into a ticketing database returns a body of data as a JSON object, use this task to convert the object and send its data as the body of an email.

Properties

InputTypeDescription
value*Required. Any valid JSON value to convert to a string. Wildcard values (*) represent any JSON value — for example, an object, array, or number.
replacerArrayAn array of String and Number objects that serve as a whitelist for selecting the properties of the value object to include in the JSON string.
spaceNumberA number used to insert whitespace into the output JSON string for readability purposes.
OutputTypeDescription
stringifiedStringA string representation of the object.

Example

The input variable value is shown in Task History, accessed from Jobs in Operations Manager.

toString (object) task showing the value input variable in Task History

The return variable shows each element in the array separated by a comma. In this example no whitespace is applied, since the space variable was not set.

toString (object) output showing the stringified value with comma-separated elements and no extra whitespace