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.
Ensure the FairCom server is installed and running.
Confirm server access by running the FairCom API Explorer (see API Explorer to learn about the user interface).
Tutorials for the table to JSON transform method
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" } ] } } ] } }
Click Apply defaults to JSON request () to replace the
"authToken"
with a valid token from your session.Click Send request ().
Observe the response and ensure the action completed successfully.
Note
"errorCode"
with a value of0
indicates success."errorCode"
with a non-zero value indicates a failure. See Errors and contact FairCom for more information about an error.
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" } }
Click Apply defaults to JSON request () to replace the
"authToken"
with a valid token from your session.Click Send request ().
Observe the response and ensure the action completed successfully.
Note
"errorCode"
with a value of0
indicates success."errorCode"
with a non-zero value indicates a failure. See Errors and contact FairCom for more information about an error.
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 ] ] } }
Click Apply defaults to JSON request () to replace the
"authToken"
with a valid token from your session.Click Send request ().
Observe the response and ensure the action completed successfully.
Note
"errorCode"
with a value of0
indicates success."errorCode"
with a non-zero value indicates a failure. See Errors and contact FairCom for more information about an error.
Navigate to and select test1 in the Server navigation window through
faircom>admin>Tables
.Click the Table Records tab.
Observe the columns and data that the transform created and stored by using the horizontal scrollbar.
Note
The
in1
andin2
fields show the inserted data fields. Theout1
field shows the data fromin1
andin2
but is transformed to JSON.