To set up a JSON connection to connect a JReport catalog to a JSON data source, follow the steps below:
If you want to set up the connection in a new data source in the catalog, select any of the existing catalog data sources, click New Data Source on the Catalog Manager toolbar, then in the New Data source dialog, specify the name of the data source, select the JSON connection type and click OK.
The JSON Connection Wizard appears.
In the URI string, you can reference parameters and constant level formulas in the current catalog data source and the special field User Name in the format "@fieldname". For example, if a URI string is http://localhost:8080/rest/getData?startDate=2016-01-01
, and you want to use the parameters pHost, pPort and pStartDate to dynamically generate the URI at runtime, then the URI string will be http://@pHost:@pPort/rest/getData?startDate=@pStartDate
. Moreover, if a URI string contains characters, such as @, '.' or double quotation marks, or other strings that do not need to be parsed, quote them with double quotation marks. If needed, you can click New Parameter to create a parameter in the current catalog data source and reference it in the URI string. If the special field User Name is used, when clicking Next in the connection wizard, the Security Identifier dialog will pop up for you to specify the user name with which to generate the stream. When you run the report on JReport Server the real user's ID will be used.
http://
or https://
protocol, the RESTful button is activated. Click it to specify the RESTful options for the sample data in the RESTful Data Source Options dialog.
When Via REST Web Service is unchecked, the remote data will be received via the protocol in the URL you specify in the Sample Data text field in the connection wizard.
To use instance data from a URI, check the URI radio button, then input the URI string directly in the Instance text field or click Browse to select the instance file. You can also reference parameters, constant level formulas and the special field User Name in the URI string. When the specified URI string begins with http://
or https://
protocol, the RESTful button is activated. Click it to specify the RESTful options for the instance data.
To use instance data from a user defined interface, check User Defined, then provide the class name with package name in the Class Name field. You can also click Browse to find the class file. The class you enter should exist and can be found by JReport Designer, which means the class should be in the class path of the system environment or in the ADDCLASSPATH in setenv.bat/setenv.sh. After filling in this field, the class name of the interface that the class implements will be displayed automatically behind The class implements:. Then specify the parameter string for the user defined interface in the Parameter box. The parameter string must match the format defined in the class. You can also reference parameters, constant level formulas, and the special field User Name in the parameter string.
http://
or https://
protocol, the RESTful button is activated. Click it to specify the RESTful options for the instance data.When a JSON connection is set up, you can manage the tables transformed from the JSON data source the same as you do with tables from an XML data source. For example, you can add more tables via the JSON connection into the JReport catalog, remove undesired table columns, organizing the tables into folder and refreshing the tables. For details, see Managing Tables in an XML Connection.
In the following example, we will set up a JSON connection to connect a JReport catalog data source to Google Cloud BigQuery. In this example, we will create two parameters in the JReport catalog and use them to provide values for the two tokens access_token and maxResults in the URL of the JSON instance file used to access Google Cloud BigQuery. The token access_token is for authorizing a Google API request, and maxResults represents the maximum record number to return. You can change the parameter values to provide dynamic values for the two tokens at runtime.
<install_root>\Demo\Reports\SampleReports
.For more information about creating parameters, see Creating a Parameter.
https://www.googleapis.com/bigquery/v2/projects/bigquery-public-data/datasets/samples/tables/gsod/data?maxResults=@pMaxResults&access_token=@pAccessToken