ActiveReports 11
Use Dynamically Built JSON Data Source
ActiveReports 11 > ActiveReports User Guide > How To > Page Report/RDL Report How To > Use Dynamically Built JSON Data Source

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:

Note:

          Create a Page Report

  1. Open ActiveReport Report Designer application.
  2. From the File menu, select New.
  3. In the Create New Report dialog box that appears, select Page Report template and then click OK.

    Add a Parameter
  4. In the Report Explorer, right-click the Parameters node and select Add Parameters option.
  5. In the Report - Parameters dialog that appears, rename the parameter as UserId, and then click OK.

    Add a Data Source
  6. 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.
  7. 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.
  8. Under Type, select JSON Provider.
  9. In the Content tab, select Expression.
  10. In the Expression field, enter an expression like the following:

    ="jsondoc=http://jsonplaceholder.typicode.com/comments/" & [@UserId] & ";schemadata=
    { ""$schema"": ""http://json-schema.org/draft-04/schema#"",
    ""type"": ""array"", ""items"": { ""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
  11. 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.
  12. In the DataSet Dialog that appears, select the General page and enter the name of the dataset.
  13. On the Query page of this dialog, select Command Type as Text and enter Query as $
  14. 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
  15. Click OK.

    Create layout for the Report
  16. Drop controls from Toolbox onto the report designer surface.
  17. Set the Value of each control to a data set field.

    Preview the Report
  18. Click the Preview tab.
  19. Enter the UserId parameter and click View report.