JSON to fields tutorial

This tutorial outlines how to transform data from JSON to fields in a different table.

 

Create an integration table with a transform

The integration table created by the following example will be the source table where data will be collected and transformed. 

{
  "api": "hub",
  "action": "createIntegrationTable",
  "params": {
    "tableName": "jsonToFieldsTable",
    "logTransformOverwrites": false,
    "fields": [
      {
        "name": "source_json_field",
        "type": "json"
      },
      {
        "name": "destination_varchar_field",
        "type": "VARCHAR",
        "length": 200
      }
    ],
    "transformSteps": [
      {
        "transformStepMethod": "jsonToTableFields",
        "mapOfPropertiesToFields": [
          {
            "recordPath": "source_json_field.sourceProperty",
            "fieldName": "destination_varchar_field"
          }
        ]
      }
    ]
  },
  "authToken": "replaceWithAuthTokenFromCreateSession"
}

 

Insert Records 

The following example inserts records into the source table.

{
  "api": "db",
  "action": "insertRecords",
  "params": {
    "tableName": "jsonToFieldsTable",
    "dataFormat": "objects",
    "sourceData": [
      {
        "source_json_field": { "sourceProperty": "FairCom Edge" }
      }
    ]
  },
  "authToken": "replaceWithAuthTokenFromCreateSession"
}

 

View records

To verify that your transform has worked, you can view the records in each table. 

First, check the source table (jsonToFieldsSource) in the table records tab to make sure the JSON records were inserted.

Second, check the target table (target_integration_table) in the table records tab and make sure the destination field "target_table_destination_field" contains the value from the JSON that was sent.