Skip to main content

Creating the Schema Description from a JSON File

To add a file as a datasource you can either manually describe the connection or you can use the Add Datasource from URL helper.

Using the Helper

We recommend using the Add Datasource from URL helper as it will automatically discover the schema details and load the datasource into the file. To do this right click onto the datasources folder and select Add Datasource from URL.

Add Datasource from URL

Then enter in a name for the datasource and the path to your JSON file. Click OK to load this into the connection file.

Load File

This generates the XML needed and the file should look similar to the code below:

<Connector name="My_API" description="" version="1.0">
<Parameters></Parameters>
<Authentication></Authentication>
<Datasources>
<Datasource name="Contacts">
<Action name="GetDataSchema">
<StaticSchemaMap>
<Column name="ID" data-type="System.Int32" />
<Column name="FirstName" data-type="System.String" />
<Column name="LastName" data-type="System.String" />
<Column name="Email" data-type="System.String" />
<Column name="AccountNumber" data-type="System.Int32" />
<Column name="SupplierID" data-type="System.Int32" />
</StaticSchemaMap>
</Action>
<Action name="GetDataTable">
<ReadFile path="C:\Temporary\DataSync\contacts.json">
<DataTableTransform path="" />
</ReadFile>
</Action>
</Datasource>
</Datasources>
</Connector>

Manually Open from file

If you want to manually define the datasource and path to the Json file then the datasource node should look similar to the example below.

In this example exchange rates are held within a JSON file on the local machine and is defined as a datasource. Note that you will need to define the schema statically if you have not used the automatic discovery method covered on the schema documentation page.

<Datasource name="fxrates">
<Action name="GetDataSchema">
<StaticSchemaMap>
<Column name="Currency" data-type="System.String" key="true" />
<Column name="Rate" data-type="System.Decimal" />
</StaticSchemaMap>
</Action>
<Action name="GetDataTable">
<ReadFile path="C:\Temporary\fxrates.json">
<DataTableTransform />
</ReadFile>
</Action>
</Datasource>