In this guide we are going to create a report that will contain a pivot table that will be populated with JSON data through a platform API.
Report Design in JasperSoft
The first thing will be to create the design from JasperSoft.
To do this we will create a simple report with a header and a table.
JSON data source
The next step is to define the parameters to fetch the data in JSON format from a platform API.
As explained in the guide https://onesaitplatform.atlassian.net/wiki/spaces/OP/pages/137330690 We will add the following parameters to the report:
And then we define the fields that we will use later:
Finally we will define the datasource that the dynamic table will need:
Now we need to modify the jr: table component to add the previously created datasource and define the dynamic fields.
The first thing is to define the dataset and the datasource:
And for each column define the field to be painted from the JSON datasource:
These fields have been defined as "fields" before.
The visual result of the report will be the following:
Report: source code
The jrxml source code of the report is attached here to use as a base.