Thursday, August 08, 2013

BIRT: Using JSON

This topic has come up quite a bit. Using JSON in BIRT Reports. This comes up for just about everything, from using as a Data Source to serializing large amounts of parameters for use in a report design. Seriously, lots of stuff.

Since the Rhino engine has not been updated to a version passed 1.7R4, there is no access to the nice Rhino JSON methods. So, we have have a few options. Since Rhino can use anything in the Java JVM, we can use any 3rd party JSON parser out there. My preference is Google GSON library. The caveat is that you must build the object structure beforehand in Java, and then use the GSON to parse a string into the object representation.

 There are other options as well, such as these: 
http://www.birt-exchange.org/devshare/_/designing-birt-reports/1053-scripted-data-source-using-json

 I ran across the old school method of using an eval() statement to do the same thing. While not as safe, this is a much simpler, quicker method, and will suffice in most cases. And example can be found here: http://www.birt-exchange.org/devshare/_/designing-birt-reports/birt-json-scripted-data-set-and-parameter-parsing-r1484

 Update: Kristopher Clark, whom is a very talented member of the BIRT community, posted something similar. In his example, he is using Apache Commons to stream in a JSON file and use as a scripted data source. This showcases BIRT's ability to leverage anything within the Java Classpath in a report execution.

BIRT: BIRT DaVinci Plugin

Recently, I had the opportunity to catch up with the author of BIRT Chart DaVinci, Keith Howard, at a BIRT get together in the Bay Area. I had previously blogged about Chart DaVinci, so it's no secret that I like it. But there was always one little issue for me, and that was the manual application of the scripts. So, after chatting with Keith, we came up with a solution. Why not build a plugin for BIRT that displays all the styles in Chart DaVinci in a gallery that the user can select and apply to a report, and the plug-in does all the work. And that is exactly what I built. So, without further ado, the BIRT Chart DaVinci Plugin is available over at the BIRT Exchange. Follow the instructions and start applying some slick, pre-done styles to your BIRT charts.