In This Topic
This article explains connecting a or an report to a JSON data source.
Connect to a JSON Data Source
- 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.
- 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.
- Under the Type field, select Json Provider.

- In the Connection Properties tab, set the type of Json data to 'External file or URL'.
- Click the dropdown next to the Select or type the file name or URL field and select the <Browse...> option to specify the json file path. For example, you can connect to the 'customers.json' sample datasource which can be downloaded from GitHub.
The Connection String tab displays the generated connection string as shown below:
jsondoc=C:\customers.json
For more information, see the Configuration Properties for Json Data Source section.
- Verify the generated connection string by clicking the Validate DataSource icon
.
- Click OK to save the changes and close the Report Data Source dialog.
Configuration Settings for JSON Data Source
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:
- External file or URL: Enter the path or URL of an external JSON data file or select the file from the drop-down which displays the JSON files available in the same folder as the report. The connection string generated using this option starts with the keyword jsondoc.
- Embedded: Enter the path of the JSON data file to embed in the report. You can enter the data manually or edit the data in selected JSON file. The connection string generated using this option starts with the keyword jsondata.
- Expression: Enter an expression to bind to the JSON data at runtime. For more information on Expressions, see Use Dynamically Built JSON Data Source topic.
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:
- type: Indicates the type of JSON schema element. See here for more information on type keyword.
- properties: Indicates the properties collection for JSON schema elements with the object type. See here for more information on properties keyword.
- items: Indicates the definition of items for JSON schema elements with array type. Only single values are supported.
For example, "items" : [ {...}, {...}, {...} ] is not supported because it contains multiple values. See here for more information on items keyword.
- definitions: Indicates the independent definitions which can be used by other JSON schema elements using $ref keyword. See here for more information on definitions keyword.
- $ref: Indicates the reference to a definition for JSON schema elements with object type. Only "definitions" ({ $ref : #/definitions/... }) references are supported.
The Connection String tab displays the JSON connection string based on the defined configuration settings in the Content and Schema tab.
- If you choose the External file or URL option, the connection string will be as follows -
jsondoc=C:\customers.json
or
jsondoc=https://demodata.grapecity.com/northwind/odata/v1/Orders
- If you choose the Embedded option, the connection string will be generated as follows -
connection string |
Copy Code
|
jsondata={"Customers":[{"Id":"ALFKI", "CompanyName":"Alfreds Futterkiste", "Country":"Germany"}, {"Id":"ANATR", "CompanyName":"Ana Trujillo Emparedados y helados", "Country":"Mexico"}], "ResponseStatus":{}}
|
- If you choose the Expression option, the connection string will start with an "equals to" as shown -
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'}"
|
Caution: If you include an expression in the connection string, use single quotes (') in jsondoc or jsondata and schemadoc or schemadata instead of the double quotes (") .
For example, the following connnection string is invalid:
connection string (invalid) |
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"}"
|