BackPrevious Page Next PageNext

Setting Up a JSON Connection

To set up a JSON connection to connect a JReport catalog to a JSON data source, follow the steps below:

  1. Create a catalog or open a catalog.
  2. In the Catalog Manager, right-click the node of a data source and choose New JSON Connection from the shortcut menu.

    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.

    JSON Connection Wizard - Extract JSON Schema

  3. In the Extract JSON Schema screen, select the schema source: Extract Schema from Sample Data or Extract Schema from Instance Data.
  4. Provide the required information for extracting the JSON schema.
  5. When parameters and formulas are referenced in the URI/parameter string, click the Edit Format button to edit the format of their values if needed.
  6. Click Next to go to the next screen.
  7. In the Modify Schema Properties screen, the elements in the JSON schema are listed in the Schema box. Select an element and modify its properties in the Properties box as required and then click Next.

    JSON Connection Wizard - Modify Schema Properties

  8. In the Transformed Relational Schema screen, check the transformed result listed in the Transformed Tables box, and then click Next.

    JSON Connection Wizard - Transformed Relational Schema

  9. In the Add Table screen, add the required tables to the connection.

    JSON Connection Wizard - Add Table

  10. Click Finish to confirm the transformed result and finalize the transformation process.

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.

Example of connecting a JReport catalog data source to Google Cloud BigQuery

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.

  1. Open the catalog file SampleReports.cat in <install_root>\Demo\Reports\SampleReports.
  2. Right-click the Parameters node in Data Source 1 of the catalog and select New Parameter from the shortcut menu.
  3. In the New Parameter dialog, input pAccessToken in the Name field.
  4. Select String from the Value Type drop-down list.
  5. Click Add button to add a value line, double-click in it and then type in the valid token value to access Google Cloud BigQuery, for example, ya29.Ci9dA2sA8J_wM8e5FnY9rJg551153GQWGbleO-y9aeZOky9V36Tz497HY1chApjLFg.
  6. Click OK to create the parameter.

    New Parameter dialog

  7. Repeat the above steps to create another parameter pMaxResults of Integer type with the prompt value 2 in the Value List.

    New Parameter dialog

    For more information about creating parameters, see Creating a Parameter.

  8. Right-click the Data Source 1 node and select New JSON Connection from the shortcut menu. The JSON Connection Wizard appears.
  9. In the Extract JSON Schema screen, select Extract Schema from Instance Data from the Schema Source drop-down list.
  10. Input the following URL in the Instance text box:

    https://www.googleapis.com/bigquery/v2/projects/bigquery-public-data/datasets/samples/tables/gsod/data?maxResults=@pMaxResults&access_token=@pAccessToken

    JSON Connection Wizard - Extract JSON Schema

  11. Click Next three times to go to the Add Table screen. Select f in the Tables box and click Add button to add it to the Added Tables box.
  12. Click Finish to set up the connection.

BackPrevious Page Next PageNext