JSON Data Provider supports dynamically built data sources. You can enter a connection string for the JSON data as an expression and pass values using parameters to set up data sources dynamically.
Steps to set up dynamically built data source are as follows:
Create a Page Report
- Open ActiveReport Report Designer application.
- From the File menu, select New.
- In the Create New Report dialog box that appears, select Page Report template and then click OK.
Add a Parameter
- In the Report Explorer, right-click the Parameters node and select Add Parameters option.
- In the Report - Parameters dialog that appears, rename the parameter as UserId, and then click OK.
Add a Data Source
- In the Report Explorer, right-click the Data Sources node and select the Add Data Source option or select Data Source from the add button.
- In the Report Data Source dialog that appears, select the General page and enter the name of the data source. 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 Type, select JSON Provider.
- In the Content tab, select Expression.
- In the Expression field, enter an expression like the following:
="jsondoc=http://jsonplaceholder.typicode.com/comments/" & Parameters!UserId.Value & ";schemadata=
{ ""$schema"": ""http://json-schema.org/draft-04/schema#"", ""type"": ""object"",
""properties"": { ""postId"": { ""type"": ""integer"" },
""id"": { ""type"": ""integer"" },
""name"": { ""type"": ""string"" },
""email"": { ""type"": ""string"" },
""body"": { ""type"": ""string"" } },
""required"": [ ""postId"", ""id"", ""name"", ""email"", ""body"" ] }}"
Add a Data Set
- In the Report Explorer, right-click the data source node (DataSource1 by default) and select the Add Data Set option or select Data Set... from the Add button.
- In the DataSet Dialog that appears, select the General page and enter the name of the dataset.
- On the Query page of this dialog, select Command Type as Text and enter Query as $.
- On the Fields page, enter the Field name and value pairs as
Name: postId; Value: postId
Name: email; Value: email
Name: name; Value: name
Name: body; Value: body
- Click OK.
Create layout for the Report
- Drop controls from Toolbox onto the report designer surface.
- Set the Value of each control to a data set field.
Preview the Report
- Click the Preview tab.
- Enter the UserId parameter and click View report.