ActiveReports 17 .NET Edition
Report Authors: Designer Components / Data Binding / Data Binding in Page/RDL Reports / Connect to a Data Source / JSON Provider
In This Topic
    JSON Provider
    In This Topic

    This article explains connecting a Page or an RDL report to a JSON data source.

    Connect to a JSON Data Source

    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 dropdown 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.grapecity.com/northwind/odata/v1/Orders' data source.

      The Connection String tab displays the generated connection string as shown below:

          jsondoc=https://demodata.grapecity.com/northwind/odata/v1/Orders

      For more information, see the Configuration Properties for JSON Data Source 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 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:

    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.

    Build Connection String

    It is possible to configure the JSON data source connection string by using the Edit 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. The Edit 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.         

    Request Body:

    Body for the POST request method. The text area is enabled only when the HTTP Method is set to POST.

    Sample connection strings and dataset queries

    1. Simple

    Connection String
    Copy Code
    jsondoc=https://demodata.grapecity.com/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[*]
    

    2. 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[*]
    

    3. 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