How can I import JSON data from a REST API into BIRT?
Asked Answered
M

1

14

I want to use BIRT to generate reports against data that comes from a JSON based REST API. How can I import this data?

Merited answered 9/1, 2013 at 4:8 Comment(0)
M
8

The process for doing this is described at http://developer.actuate.com/community/forum/?app=blog&blogid=45&showentry=471, but it turns out that there are a few important steps missing. I'll fill in a few blanks here.

The original instructions describe creating a Scripted Data Source, with an "open" script that makes use of the com.actuate.json.JSONParser class. First, it is important to realise that this class is not part of BIRT, and needs to be manually added (along with any dependencies).

The download provided by the original instructions provides the com.actuate.json.JSONParser class, but leaves it up to you to source the dependencies. To make things easier I have reimplemented the JSONParser library in Maven, which will then download and package the dependencies for you. It also includes some bug fixes and enhancements like GZIP compression support. You can get the Maven project from https://github.com/mcasperson/birt-jsonparser, and to build the JSONParser library and package the dependencies, run the command

mvn clean package dependency:copy-dependencies

This will result in the birt-jsonparser-0.0.1-SNAPSHOT.jar file being created in the target directory, and all the dependencies copied into the target\dependency directory. Copy all of these JAR files into the {BIRT_INSTALL}/plugins/org.eclipse.birt.report.viewer_{BIRT_VIEWER_VERSION}/birt/scriptlib directory to allow the JSONParser class to be accessed from within your BIRT report.

If you want to debug your report, these JAR files will also have to be referenced in the Debug profile.

enter image description here

Merited answered 9/1, 2013 at 4:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.