Skip to main content

JSON to fields API reference

API reference for the JSON to fields transform method

Request examples

Minimal

{
  "api": "hub",
  "apiVersion": "1.0",
  "action": "createIntegrationTable",
  "params": {
    "tableName": "test1",

    "fields": [
      {
        "name": "In1",
        "type": "json"
      },
      {
        "name": "Out1",
        "type": "varchar"
      }
    ],

    "transformSteps": [
      {
        "transformStepMethod": "jsonToTableFields",
        "mapOfPropertiesToFields": [
            {
                "recordPath": "in1.out1",
                "fieldName": "out1"
            }
        ]
      }
    ]
  },
  "authToken": "replaceWithAuthTokenFromCreateSession"
}

The following example is not the maximal example for creating an integration table, rather it is the maximal example for creating a JSON to fields transform.

{
  "api": "hub",
  "apiVersion": "1.0",
  "action": "createIntegrationTable",
  "params": {
    "tableName": "test1",
    "ownerName": "admin",
    "databaseName": "faircom",

    "fields": [
      {
        "name": "In1",
        "type": "json"
      },
      {
        "name": "Out1",
        "type": "varchar"
      },
      {
        "name": "Out2",
        "type": "float"
      }
    ],

    "transformSteps": [
      {
        "transformStepMethod": "jsonToTableFields",
        "mapOfPropertiesToFields": [
            {
                "recordPath": "in1.out1",
                "fieldName": "out1"
            },
            {
                "recordPath": "in1.out2",
                "fieldName": "out2"
            }
        ]
      }
    ]
  },
  "authToken": "replaceWithAuthTokenFromCreateSession"
}
{
    "result": {},
    "requestId": "00000007",
    "errorCode": 0,
    "errorMessage": "",
    "authToken": "replaceWithAuthTokenFromCreateSession"
}

API reference for the JSON to fields transform method

API referenceJSON hub APIJSON API referenceJSON to fields transformJSON fields

The "params" property is an object that contains an action's request parameters as defined by a set of properties. Each action defines its own required and optional properties. See System limits for a comprehensive overview of property requirements and limitations.

Table 1. "params" property summaries

Property

Description

Default

Type

Limits

databaseName

(optional) specifies the name of a database.

Defaults to the "defaultDatabaseName" value that is set during "createSession". If no default is set during "createSession", then "faircom" is used.

string

1 to 64 bytes

fields

(optional) contains objects that specify the settings of a field in a table.

[]

array of objects

0 or more objects

fields
.name

(optional) specifies the name of a field.

""

string

0 to 64 bytes

fields
.type

(optional) specifies the data type of a field.

""

string

see link

ownerName

specifies the account that owns an object, such as a table or code package.

""

string

1 to 64 bytes

tableName

(optional) specifies the name of a table.

""

string

1 to 64 bytes

transformSteps

specifies an array of transform objects.

Required - No default value

array of objects

0 or more objects

transformSteps
.mapOfPropertiesToFields

(optional) specifies the field in the table to be mapped to a field containing JSON properties.

[]

array

"binaryFormat"
"dateFormat"
"fieldName"
"numberFormat"
"recordPath"
"timeFormat"
"variantFormat"
transformSteps
.mapOfPropertiesToFields
.fieldName

specifies the name of a field in a table.

Required - No default value

string

1 to 64 bytes

transformSteps
.mapOfPropertiesToFields
.recordPath

specifies the location in a record where the server reads or writes a JSON value.

Required - No default value

string

0 to 256 bytes

transformSteps
.transformStepMethod

specifies the transform method the step will use.

Required - No default value

string enum

"javascript"
"jsonToDifferentTableFields"
"jsonToTableFields"
"tableFieldsToJson"


The "databaseName" property is an optional string that specifies the database that contains the tables. It defaults to the database name supplied at login.

Note

In the API Explorer, "defaultDatabaseName" is set to "ctreeSQL" in the "createSession" action that happens at login.

  • A zero-length "databaseName" is invalid.

  • Its length limit is from 0 to 64 bytes.

  • If the "databaseName" property is omitted or set to null, the server will use the default database name specified at login.

  • If no default database is specified during "createSession", "databaseName" will be set to the "defaultDatabaseName" value that is specified in the services.json file.

"params": {
  "databaseName": "mainDatabase"
  }

The "fields" property is an array of objects. It is required when creating a table. Each object in the array defines a field by specifying its properties.

Example

"fields": [
  {
    "autoValue": "none",
    "name": "name",
    "type": "varchar",
    "length": 50,
    "scale": null,
    "defaultValue": null,
    "nullable": false
  }
]

The "name" property is a required string. It is the field named that is mapped to the property name specified in "propertyPath".

Things to know:
  • It must be <= 64 ASCII characters.

  • It must be unique in the table.

  • It should be lowercase with underscores separating the parts of the name; otherwise, SQL requires you to enclose the name in double quotes.

  • A field name is case-sensitive in JSON NAV and in SQL.

    In SQL, a quoted field name is case sensitive and an unquoted field name can be any case but it only matches a lowercase field name. Because of this complexity in SQL, use lowercase field names.

  • When c-tree receives a data message, it extracts the value from the JSON property specified by "propertyPath" and stores it in the table field specified by this "name" property.

The "type" property is a required string that defines the data type of the field in the table. See Data Types in the FairCom DB SQL Reference Guide for full documentation on FairCom field types.

Things to know:
  • If a field is configured incorrectly, the operation fails. FairCom logs an error to its CTSTATUS.FCS file.

  • You can first create a table in SQL and then create a Persistence Topic that is assigned to that table.

  • Some SQL types are not specified in the list of MQTT types.

    Table 2. How Additional SQL Types Map to MQTT Types

    SQL

    MQTT

    LVARCHAR

    LVARBINARY

    NUMERIC

    NUMBER

    DECIMAL

    NUMBER

    MONEY

    NUMBER

    FLOAT

    DOUBLE



  • Valid field types include:

    • "DATE"

      stored as days since March 1, 1700

    • "TIME"

      stored as milliseconds since midnight

    • "TIMESTAMP"

      stored as a date and a time

    • "TINYINT"

      8-bit Integer

    • "SMALLINT"

      16-bit Integer

    • "INTEGER"

      32-bit Integer

    • "BIGINT"

      64-bit Integer (-9223372036854775807 to 9223372036854775806, which is 1 "inward" from the industry standard of -9223372036854775808 to 9223372036854775807)

    • "MONEY"

      10 decimal digits with 2 decimal places

    • "NUMBER"

      32 decimal digits with N decimal places specified by the "scale" property

    • "REAL"

      32-bit IEEE binary floating point number

    • "DOUBLE"

      64-bit IEEE binary floating point number

    • "CHAR"

      Fixed-length ASCII string <= 8,192

    • "NCHAR"

      Fixed-length UTF-16 string <= 65,535

    • "VARCHAR"

      Variable-length ASCII string <= 8,192

    • "LVARCHAR"

      Variable-length ASCII string <= 2GB

    • "NVARCHAR"

      Variable-length UTF-16 string <= 65,535

    • "BIT"

      Boolean that interprets the listed values as 0 and all others are interpreted as 1

      The values are interpreted as 0:
      • 0

      • 0.0

      • -0

      • false (using any case)

      • an empty string

      • null

      • { }

      • [ ]

    • "BINARY"

      Fixed-length array of bytes <= 8,192

    • "VARBINARY"

      Variable-length array of bytes <= 65,535

    • "LVARBINARY"

      Variable-length array of bytes <= 2GB

    • "JSON"

      Variable-length UTF-16 string <= 65,535

      Note

      "CURRENCY" is currently an unsupported field type. "CURRENCY" is a 19 decimal digits with 4 decimal places.

The "ownerName" property is an optional string from 1 to 64 bytes that specifies the account that owns an object, such as a table or code package. If it is set to null or is omitted, it defaults to the account that created the JSON Action session, see "createSession" and the "defaultOwnerName" property. 

You specify this property when you want to use a different account instead of the default. Your session's account must have the appropriate privileges to access the code package. 

This property is useful because objects, such as tables and code packages, can have the same name in the same database as long as different accounts own each object. This feature allows you to create duplicate objects for different users on the same server and reuse the same JSON actions on those objects. For example, an administrator can copy objects from a production environment to her account so she can troubleshoot an issue using the same JSON actions, JavaScript, and SQL code.

It is an error to set "ownerName" to the empty string "".

If no default owner is specified during "createSession", the server sets the "defaultOwnerName" to the "defaultOwnerName" value specified in the services.json file.

The "tableName" property contains the name of the table in the database where the event occurred. It is a non-zero-length string.

See table name in System limits for table naming requirements and limitations.

A table in DBnotify is defined by "databaseName", "ownerName" and "tableName" or by "dataFilePath".

The "transformSteps" property is an array of transform step objects. 

Different actions interpret "transformSteps": [] differently.

  • In the "alterIntegrationTable" action, "transformSteps" is optional. Setting it to [] removes transform steps from the integration table.

  • In the "createIntegrationTable" action, "transformSteps" is optional. Setting it to [] is the same as setting it to null or omitting it.

  • In the "testIntegrationTableTransformSteps" actions, "transformSteps" is required; thus, omitting it or setting it to [] or null is an error.

Each transform step object contains the required "transformStepMethod" property. It also supports the following optional properties:

  • "transformStepName"

  • "transformStepService"

Each transform step method also supports unique properties that are defined below.

"transformStepMethod": "javascript"

  • Required properties

    • "codeName"

  • Optional properties

    • "ownerName"

    • "databaseName"

"transformStepMethod": "tableFieldsToJson"

  • Required properties

    • "mapOfPropertiesToFields"

"transformStepMethod": "jsonToTableFields"

  • Required properties

    • "mapOfPropertiesToFields"

"transformStepMethod": "jsonToDifferentTableFields"

  • Required properties

    • "mapOfPropertiesToFields"

    • "targetTableName"

  • Optional properties

    • "targetOwnerName"

    • "targetDatabaseName"

The "mapOfPropertiesToFields" property takes fields in the table and maps them to a field containing JSON properties. It is an array of property map objects. Each object maps a field in a table to a JSON property in another field.

  • Required properties

    • "recordPath"

    • "fieldName"

  • Optional properties

    • "binaryFormat"

    • "numberFormat"

    • "variantFormat"

    • "dateFormat"

    • "timeFormat"

The required "fieldName" property specifies a field in a record. Depending on the context, the server reads or writes the field's value. 

For example, in the "tableFieldsToJson" transform method, "fieldName" is the location where the transform step reads a value that it transforms.  In the "jsonToTableFields" and "jsonToDifferentTableFields" transform methods, "fieldName" is the location where the transform step writes a transformed value.

The "recordPath" property specifies the location in a record where the server reads or writes a JSON value. It specifies a field name followed by an optional JSONPath. Depending on the context, it refers to a value the server reads or writes. 

For example, in the "tableFieldsToJson" transform method, "recordPath" is the location where the transform step writes a transformed value.  In the "jsonToTableFields" and "jsonToDifferentTableFields" transform methods, "recordPath" is the location where the transform step reads the value that it transforms.

  • The "recordPath" property must always include a field name.

    • The server returns an error when the field name is missing or does not exist.

  • The "recordPath" property may include a JSONPath after the field name.

    • If no JSONPath follows the field, the "recordPath" property refers to the entire field, and the field is not required to contain a JSON document.

    • If a JSONPath follows the field, the "recordPath" property refers to a part of the JSON document inside the field.

Several FairCom APIs, such as the DB and Transform APIs, treat each record in each table as a JSON document. The top-level fields in the record are treated as top-level properties in the JSON document. In other words, you can think of each record as a JSON document, and you can use the "recordPath" property to refer to any field in the record and any JSON property or array item within a JSON field.

When the server writes a value to a "recordPath", it looks for the specified field and JSONPath and does the following.

  • If the specified field does not exist, the server returns an error.

  • If the JSONPath is not specified after the fieldname, the server writes the value directly to the field.

  • If the field's value does not contain a JSON document, the server returns an error.

  • If the JSONPath specifies a property or array item that does not exist in the field's JSON document, the server adds it.

  • If the JSONPath specifies a property or array item that already exists in the field's JSON document, the server replaces the value.

When the server reads a value from a "recordPath", it looks for the specified field and JSONPath and does the following.

  • If the specified field does not exist, the server returns an error.

  • If the JSONPath is not specified after the fieldname, the server reads the entire field value.

  • If the field's value does not contain a JSON document, the server returns an error.

  • If the JSONPath specifies a property or array item that does not exist in the field's JSON document, the server returns null because FairCom's data model treats a missing JSON property the same as one assigned to null.

  • If the JSONPath specifies a property or array item that already exists in the field's JSON document, the server replaces the value.

Note

Unlike "propertyPath", a "recordPath" includes the name of the field that contains the JSON document.

Simple "recordPath" example

For example, a recordPath of "temperature" refers to a field named "temperature".

Example record in an integration table

The following record contains three fields: id, source_payload, and create_ts.

id

source_payload

create_ts

1

{
  "humidity": 
  [
    {
      "temperature": 20.1,
      "pressure": 1003
    }
  ]
}

"2025-07-07T14:14:02.012"

JSON representation of the example record

The following JSON shows how the JSON DB and Transform APIs represent the previous record. The top-level properties are fields in the integration table.

{
  "id": 1,
  "source_payload": 
  {
    "humidity": 
    [
      {
        "temperature": 20.1,
        "pressure": 1003
      }
    ]
  },
  "create_ts": "2025-07-07T14:14:02.012"
}

"recordPath" properties for each value in the example record

"recordPath"

Field Value

"recordPath": "id"

1

"recordPath": "source_payload"

{
  "humidity": 
  [
    {
      "temperature": 20.1,
      "pressure": 1003
    }
  ]
}

"recordPath": "source_payload.humidity"

[
  {
    "temperature": 20.1,
    "pressure": 1003
  }
]

"recordPath": "source_payload.humidity[0]"

{
  "temperature": 20.1,
  "pressure": 1003
}

"recordPath": "source_payload.humidity[0].temperature"

20.1

"recordPath": "source_payload.humidity[0].pressure"

1003

"recordPath": "create_ts"

"2025-07-07T14:14:02.012"

The required "recordPath" property specifies the location of a JSON property in a record. It starts with the name of a field in the table followed by an optional JsonPath to a JSON property within that field.

The "transformStepMethod" property is a required string that specifies the type of transform, such as the "javascript" transform method that runs JavaScript to change the table's data or the "jsonToTableFields" transform method that extracts values from properties in a JSON field and stores them in other fields.

Note

The "transformStepMethod" property replaces the deprecated "transformActionName" property.

The value of the "transformStepMethod" affects the value of the "transformService" property. The following table defines the possible values of the "transformService" property when combined with the "transformStepMethod". Notice that some transform step methods are built into the server and do not require you to specify the "transformService".

"transformStepMethod" value

"transformService" value

"jsonToTableFields"

null or omitted

"tableFieldsToJson"

null or omitted

"jsonToDifferentTableFields"

null or omitted

"javascript"

"v8TransformService"

"siemensUdtPayloadToJson"

"siemensUdtPayloadToJson"

Note

If the "transformStepMethod" property is set to "javascript", the "transformService" property must be set to "v8TransformService".