Skip to content

This provides a subtask to convert a Cortex structure to JSON, according to a provided mapping specification

Notifications You must be signed in to change notification settings

IntelligentAutomationCommunity/Cortex-Convert-to-JSON

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

Cortex-Convert-to-JSON

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

Object Specifications

If i_object_type is OBJECT

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:

  1. JSON-object-name - the value to be used in the JSON for the name of the field
  2. JSON-object-type - the type of this field; can take values TEXT, NUMBER, BOOLEAN, OBJECT or ARRAY
  3. specification - for fields of type OBJECT or ARRAY, the specification of the value of the field
  4. JSON-included-fields - for fields of type OBJECT, the sub-fields to include in the output

If i_object-type is ARRAY

The i_object-specification parameter is a Strcture with the following fields:

  1. JSON-object-type - the type of every element in the List; can take values TEXT, NUMBER, BOOLEAN, OBJECT or ARRAY
  2. specification - the specification of the value of every element in the List
  3. JSON-included-fields - for fields of type OBJECT, the sub-fields to include in the output

Installation Instructions

Download the Studio Package file and Import it into your Cortex Environment. Don't forget to apply rights using the Studio Authorization module.

👍 Enjoy! 😉

About

This provides a subtask to convert a Cortex structure to JSON, according to a provided mapping specification

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published