Prerequisite: Jasper Studio, MYSQL, Jasper sever
Make data easy with Helical Insight.
Helical Insight is the world’s best open source business intelligence tool.
I have come across one issue, our client has data in JSON format for one field and he is expecting to create a report like below format
Json Format : { "alert_events": [ {"event":"FD Alert","date_created":"2018-07-29 17:47:18<br />Africa/Abidjan","info":"Location: 22.9465931 -25.4185405","extra":""} ,{"event":"Received","date_created":"2018-07-29 17:47:20<br />Africa/Abidjan","info":"","extra":""}, {"event":"Acknowledged","date_created":"2018-07-29 17:47:26<br />Africa/Abidjan","info":"","extra":""}, {"event":"Resolved","date_created":"2018-07-29 17:49:43<br />Africa/Abidjan","info":"without_dispatch","extra":""}, {"event":"Alert Note","date_created":"2018-07-29 17:49:38<br />Africa/Abidjan","info":"2018-07-29 13:47:26 ","extra":""} ] }
Data in Table
Expected Output
To achieve above output we need use Scriplet concept in Jasper nothing but one Java Program to convert JSON format to a list format then we can pass that list to report
In Java program, we need to use two classes one is Bean Class and other for Conversation.
Bean Class:
JSON Conversation:
We need to convert this program to jar and place that JAR at Jasper lib folder and also dependencies jar also
Create a Scriptlet in Jasper and class we need to give package name along with class name
Make data easy with Helical Insight.
Helical Insight is the world’s best open source business intelligence tool.
I have created a Main Report and One SubReport
Main Report I have placed device_user and device_id, Organization name in Group
Sub Report I am passing the main object which names as alert_events in the datasource expression
In SubReport just I have placed the attributes names in detail band, here we no need to write any SQL in the main dataset
If you need to check the output in Jasper Studion then we need main and dependency jars in Report Library
Come to main Report and preview the output is as follows
Make data easy with Helical Insight.
Helical Insight is the world’s best open source business intelligence tool.
Best Open Source Business Intelligence Software Helical Insight is Here
A Business Intelligence Framework
If you have any queries please get us at support@helicaltech.com
Thank You
Satya Gopi
create Json datasource in jasper server Code Example Create table element using Json data souce Jaspersoft display json array in table on jasper report How do I add a column to a table in Jasper report How do you use tables in Jasper report How to Create a Jasper Report Using JSON Data in Table Format How To Generating Table Report via JSON data-source jasper jasper report jaspersoft jaspersoft report JSON