- 15 Sep 2023
-
DarkLight
-
PDF
toString (object)
- Updated on 15 Sep 2023
-
DarkLight
-
PDF
Purpose
The toString (object) task is used to convert a valid JSON value to a JSON string, optionally replacing values if a replacer function is specified or optionally including only the specified properties if a replacer array is specified.
Potential Use Case
Given a JSON object as the input, this task returns a string containing all JSON object properties separated by commas. If a recent query into a ticketing database has a body of data in a JSON object, you could use this method to convert the JSON object and send its data as the body of an email.
Parameters
Input and output parameters are shown below.
Input | Type | Description |
---|---|---|
value |
* | Required. Any valid JSON value to be converted to a string. Wildcard values (*) represent any JSON value. For example, an object, array, or number. |
replacer |
Array | An array of String and Number objects that serve as a whitelist for selecting/filtering the properties of the value object to be included in the JSON string. |
space |
Number | A number that’s used to insert white space into the output JSON string for readability purposes. |
Output | Type | Description |
---|---|---|
stringified |
String | A string representation of the object. |
Examples
In the IAP examples shown below:
-
The input variable ("value") is shown in the Task History, which is accessed from Jobs in Operations Manager.
-
The return variable shows each element in the array separated by a comma. In this example, no white space is used since we did not set a spacer variable.