Report Authors / Data Binding / Data Binding in Page/RDLX Reports / Connect to a Data Source / JSON
JSON

This article explains connecting a Page or an RDLX report to a JSON data source. You can connect to this data source while creating a new report (via report wizard) or using report explorer (via report data source dialog).

Connect to JSON Data Source using Report Wizard

The steps to connect to the JSON data source are:

  1. Create a New Report.
  2. In the New Report dialog, choose the Report Type as RDLX, RDLX Dashboard, or Page and click Next.
    Choose a Report Type from New Report Dialog
  3. Configure page settings if you need to customize the report page settings and click Next >.
    Configure Page Settings of the Report Wizard
  4. Select the Data Source Type as JSON and click Next.
    Select the Data Source Type as JSON
  5. To specify JSON File Path, click the Browse button and navigate to the desired file on your system. For example, you can connect to the 'customer.json' sample data source that can be downloaded from GitHub.
    Specify JSON file path
  6. To specify the runtime connection values, click Parameter to open the Parameters dialog. Then click the Add button to add a new parameter, or select the existing parameter and specify the below details:
    • Name: Specify the name of the parameter.
    • Type: Select the value type (string by default) from the drop-down list.
    • Testing Value: Specify the runtime value for the connection properties.
    • Input Source: Select Interactive for non-hidden parameters and Programmatic for hidden parameters from the drop-down list.
      Parameters Dialog
  7. Click the Next option and configure the dataset by adding a valid query. Select the node from the data tree in the Path section to generate the path. The resulting query is displayed in the Query field.

    Configure the dataset by adding a valid query
  8. On the final screen of the Report Wizard, review the summary of the report and click Finish to successfully add the report with the JSON data source.

Connect to a JSON Data Source using Report Data Source dialog

  1. In the designer, go to the Report Explorer, right-click the Data Sources node and select the Add Data Source option or click the Add button and then select the Data Source option.
  2. In the Report Data Source dialog that appears, select the General page and enter the name of the data source in the Name field. By default, the data source name is set to DataSource1. This name appears as a child node to the Data Sources node in the Report Explorer.
  3. Under the Type field, select Json Provider.
    JSON Provider Data Source
  4. In the Content tab, set the type of Json data to 'External file or URL'.
  5. Click the drop-down icon next to the Select or type the file name or URL field and select the <Browse...> option to specify the json file path, or enter the URL. For example, connect to the 'https://demodata.mescius.io/northwind/odata/v1/Orders' data source.
    The Connection String tab displays the generated connection string as shown below:
    Connection String
    Copy Code
    jsondoc=https://demodata.mescius.io/northwind/odata/v1/Orders
    

    The Configuration Settings are explained in the next section.

  6. Verify the generated connection string by clicking the Validate DataSource icon Validate Icon in Report Data Source Dialog Box.
  7. Click OK to save the changes and close the Report Data Source dialog.

Configuration Settings

The JSON Data Provider provides the following configuration settings under the Connection section in the Report Data Source dialog.

The Content tab describes the type of JSON data you want to use for connecting to a data source. The options available for specifying the JSON data are as follows:

The Schema tab describes the options available for specifying the JSON schema in ActiveReports.

The JSON schema describes the structure of the JSON data. In ActiveReports, the JSON data provider uses the JSON schema to obtain fields. For more information on JSON schema, please see https://json-schema.org/understanding-json-schema/.
JSON data provider does not support the following schema keywords, such as:

The Connection String tab displays the JSON connection string based on the defined configuration settings in the Content and Schema tab.

Connection String
Copy Code
jsondoc=C:\customers.json

or

Connection String
Copy Code
jsondoc=https://demodata.mescius.io/northwind/odata/v1/Orders

Connection String
Copy Code
jsondata={"Customers":[{"Id":"ALFKI", "CompanyName":"Alfreds Futterkiste", "Country":"Germany"}, {"Id":"ANATR", "CompanyName":"Ana Trujillo
                    Emparedados y helados", "Country":"Mexico"}], "ResponseStatus":{}}

 

Connection String
Copy Code
="jsondata={""Name"":""Name""};schemadata={""$schema"":""http://json-schema.org/draft-04/schema#"",""definitions"":{},""id"":""http://example.com/example.json"",""properties"":{""Name"":{""id"":""/properties/Name"",""type"":""string""}},""type"":""object""}"

Build Connection String

It is possible to configure the JSON data source connection string by using the Build button in the Connection String tab of the Report Data Source - General dialog. This allows fetching a JSON from an external URL using the specified method (GET, POST) and other request options. Clicking the Build button opens the Configure JSON Data Source dialog where you can create a JSON connection string with parameters such as data path, method (GET, POST), headers, and body.

To connect to a external URL containing JSON data, some settings are required to be configured as elaborated.

Data Path:

The URL or the endpoint of the request consists of service root URI, resource path, and query options. The fields from json provided in the data source's endpoint are extracted depending on the dataset’s settings. A URL with IP address (eg. http://10.64.2.17:51980/admin) or with a machine name (eg. http://in-esxi-w10v17:8080/) is also valid.

Note: The Data Path must be accurate with a valid URL, else it can not be validated by the builder.

HTTP Headers:

Contains additional info related to the request or the response, for eg, provide expected content type necessary for establishing connection with endpoint which must return json. For example, providing credentials to login to a service/URI to retrieve data. Collection editor to add header/value pair for headers is available. This parameter has to be set to send the request body in JSON format.

Example of Header,Value pairs:

HTTP Method:

Request method can be GET (included in URL) or POST (included in 'body').

Request Body (POST):

Text area, applicable only in case of POST HTTP request.

You should provide a valid combination of configuration settings for the successful processing of the connection string with the POST method. If a combination of a valid URL, a valid header name, a valid header value, and a valid body is provided, then the connection string can be saved and validated. Only in this case, it is possible to create a dataset based on this data source.

If an invalid URL, an invalid header name or header value, invalid body, or a combination of these settings is entered, error message is displayed while validating the connection string.         

Sample connection strings and dataset queries

Simple

Connection String
Copy Code
jsondoc=https://demodata.mescius.io/northwind/api/v1/Categories
Dataset Query
Copy Code
$.[*]

To convert the format of data in the requested URI to JSON, use either $format query or Http Header as shown in the following connection strings:

Connection String
Copy Code
jsondoc=https://services.odata.org/v3/northwind/northwind.svc/Invoices?$format=json
Connection String
Copy Code
headers={"Accept":"application/json"};jsondoc=https://services.odata.org/v3/northwind/northwind.svc/Invoices
Dataset Query
Copy Code
$.value[*]

Using Parameters to query specific fields

Connection String
Copy Code
headers={"Accept":"application/json"};jsondoc=https://services.odata.org/v3/northwind/northwind.svc/Invoices?$select=ShipName,ShipRegion
Dataset Query
Copy Code
$.value[*]

Using Parameters to filter database fields

Connection String
Copy Code
headers={"Accept":"application/json"};jsondoc=https://services.odata.org/v3/northwind/northwind.svc/Invoices?$filter=ShipName eq 'Alfreds%20Futterkiste'
Dataset Query
Copy Code
$.value[*]
See Also