JSON to fields tutorial
Tutorial to transform JSON to fields in the same table
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).
Tutorial to transform JSON to fields in the same table
Replace the JSON in the API Request editor with the following JSON:
{ "api": "hub", "action": "createTransform", "authToken": "AuthorizedToken", "params": { "transformName": "TestTransform2", "transformActions": [ { "inputFields": [ "In1" ], "outputFields": [ "Out1", "Out2" ], "transformActionName": "jsonToTableFields", "transformParams": { "mapOfPropertiesToFields": [ { "propertyPath": "out1", "name": "out1", "type": "VARCHAR", "length": 200 }, { "propertyPath": "out2", "name": "out2", "type": "DOUBLE" } ] } } ] } }
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
"params"
property values with the following"params"
values:{ "api": "hub", "action": "createIntegrationTable", "authToken": "AuthorizedToken", "params": { "databaseName": "faircom", "tableName": "test2", "fields": [ { "name": "In1", "type": "JSON", "length": 100 } ], "transformName": "TestTransform2" }, "requestId": "00000006" }
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": "db", "action": "insertRecords", "authToken": "AuthorizedToken", "params": { "tableName": "test2", "dataFormat": "arrays", "databaseName": "faircom", "fieldNames": [ "In1" ], "sourceData": [ [ { "out1": "Text data 1.", "out2": 1 }], [{ "out1": "Text data 2.", "out2": 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.
In the API Explorer navigation window, navigate to
faircom>admin>Tables
and select test2.Note
If you do not see test2, refresh Tables.
Click the Table Records tab.
Observe the out1 and out2 data that was transformed when the JSON object was added in Add records to the integration table