How to create a report with a pivot table and JSON data

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 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:

PivotTable Datasource

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.


(c) 2020 Indra Soluciones Tecnologías de la Información, S.L.U.