Skip to main content

Table to JSON tutorials

Tutorials for the table to JSON transform method

The tutorials in this section show how to take new records that are added to an integration table, transform them into JSON, and store that JSON in a new field in the same table and record.

Requirements:

Tutorials for the table to JSON transform method

tutorialtable to JSONtransform methodJSON transform
  1. Replace the JSON in the API Request editor with the following JSON:

    {
      "api": "transform",
      "authToken": "AuthorizedToken",
      "action": "createTransform",
      "params": {
        "transformName": "TestTransform1",
        "transformations": [
          {
            "inputFields": [
              "In1", "In2"
            ],
            "outputFields": [
              "Out1"
            ],
            "transformActionName": "tableFieldsToJson",
            "transformParams": {
              "mapOfFieldsToProperties": [
              {
                "propertyPath": "In1",
                "fieldName": "In1"
              },
              {
                "propertyPath": "In2",
                "fieldName": "In2"
              }
              ]
            }
          }
        ]
      }
    }
    
  2. Click Apply defaults to JSON request (Apply.PNG) to replace the "authToken" with a valid token from your session.

  3. Click Send request (Runbutton.png).

  4. Observe the response and ensure the action completed successfully.

    Note

    "errorCode" with a value of 0 indicates success. "errorCode" with a non-zero value indicates a failure. See Errors and contact FairCom for more information about an error.

  1. Replace the JSON in the API Request editor with the following JSON:

    {
        "api": "hub",
        "authToken": "AuthorizedToken",
        "action": "createIntegrationTable",
        "params": {
            "databaseName": "faircom",
            "tableName": "test1",
            "fields": [
            {
                "name": "In1",
                "type": "VARCHAR",
                "length": 100
            },
            {
                "name": "In2",
                "type": "INTEGER"        },
            {
                "name": "Out1",
                "type": "VARCHAR",
                "length": 200
            }],
            "transformName": "TestTransform1"
        }
    }
    
  2. Click Apply defaults to JSON request (Apply.PNG) to replace the "authToken" with a valid token from your session.

  3. Click Send request (Runbutton.png).

  4. Observe the response and ensure the action completed successfully.

    Note

    "errorCode" with a value of 0 indicates success. "errorCode" with a non-zero value indicates a failure. See Errors and contact FairCom for more information about an error.

  1. Replace the JSON in the API Request editor with the following JSON:

    {
        "authToken": "AuthorizedToken",
        "api": "db",
        "action": "insertRecords",
        "params": {
            "tableName": "test1",
            "dataFormat": "arrays",
            "databaseName": "faircom",
            "fieldNames": [
                "In1",
                "In2"
            ],
            "sourceData": [
                [
                    "Text data 1",
                    1
                ],
                [
                    "Text data 2",
                    2
                ]
            ]
        }
    }
    
  2. Click Apply defaults to JSON request (Apply.PNG) to replace the "authToken" with a valid token from your session.

  3. Click Send request (Runbutton.png).

  4. Observe the response and ensure the action completed successfully.

    Note

    "errorCode" with a value of 0 indicates success. "errorCode" with a non-zero value indicates a failure. See Errors and contact FairCom for more information about an error.

  1. Navigate to and select test1 in the Server navigation window through faircom>admin>Tables.

  2. Click the Table Records tab.

  3. Observe the columns and data that the transform created and stored by using the horizontal scrollbar.

    Note

    The in1 and in2 fields show the inserted data fields. The out1 field shows the data from in1 and in2 but is transformed to JSON.