This provides a subtask to convert a Cortex structure to JSON, according to a provided mapping specification
This subtask accepts the following parameters:
Input parameter Name | Description | Type | M/O |
---|---|---|---|
i_JSON | Any existing JSON to which the converted strcuture will be appended | Text | O |
i_object-to-convert | The Cortex object which is to be converted to JSON | Any | M |
i_object-specification | The specification of the mapping to JSON for the object being converted | Structure | M |
i_type | The type of the object being converted, must be one of TEXT, NUMBER, BOOLEAN, OBJECT (for Cortex Structures), ARRAY (for Cortex Lists) | Text | O - defaults to TEXT) |
i_indent | Any existing indent which is added to the start of each line | Text | O |
i_indent-size | The nuber of spaces to increase the indent by on sub-objects | Integer | O (defaults to 4) |
i_included-fields | A specification of fields to include in the JSON output; only used if i_object-type is OBJECT | Structure | O (if not provided, all fields are included) |
The subtask returns the following parameters:
Output parameter Name | Description | Type |
---|---|---|
o_JSON | The JSON representing the structure | Text |
The i_object-specification parameter is a Structure with the same fields as are present in the i_object-to-convert Structure. The value of each field in the i_object-specification Structure is a Structure with the following fields:
- JSON-object-name - the value to be used in the JSON for the name of the field
- JSON-object-type - the type of this field; can take values TEXT, NUMBER, BOOLEAN, OBJECT or ARRAY
- specification - for fields of type OBJECT or ARRAY, the specification of the value of the field
- JSON-included-fields - for fields of type OBJECT, the sub-fields to include in the output
The i_object-specification parameter is a Strcture with the following fields:
- JSON-object-type - the type of every element in the List; can take values TEXT, NUMBER, BOOLEAN, OBJECT or ARRAY
- specification - the specification of the value of every element in the List
- JSON-included-fields - for fields of type OBJECT, the sub-fields to include in the output
Download the Studio Package file and Import it into your Cortex Environment. Don't forget to apply rights using the Studio Authorization module.
👍 Enjoy! 😉