I'm using below code to generate pdf using JsonDataSource and Jasperreport library.
InputStream input = new FileInputStream(new File("JsonExample.jrxml"));InputStream is = new FileInputStream("search.json");JsonDataSource app = new JsonDataSource(is);JasperDesign jasperDesign = JRXmlLoader.load(input);JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, new HashMap<String, Object>(), app);OutputStream out = new FileOutputStream(new File("raport.pdf"));JasperExportManager.exportReportToPdfStream(jasperPrint, out);
When I'm generating this report in Jasper Studio data fileds are correctly displayed (are not empty), but when I'm using above code, generated report contains onlny static text fields, there are no data fields with values read from json file. How to use Jasperreport library and JsonDataSource (5.5. version)?
0 Answers:
No answers yet
I have the same problem too. Is there any solutions for this?
In my case, I fill the report using the following:
File file = new File("src/main/resources/data/simple.json");
JsonDataSource ds = new JsonDataSource(file);
JasperFillManager.fillReportToFile("src/main/resources/reports/json-simple.jasper", null, ds);
I am using 5.5 version as well. I tried to fill the report using json with ireport and it does not show the fields.
I am not sure about file input - what I've done is String input which is a json -
reportDef is nothing but JasperReportDef in grails- jasper plugin. One doesn't have to use this though.
This one works perfect.
Could you post your JsonExample.jrxml?
What is "_defaultJSONSelectExpression"? I was having the same problem and switched to using the InputStream and am still getting no data in my report.
Have a look at the JSON DataSource sample: http://jasperreports.sourceforge.net/sample.reference/jsondatasource/ind...
Thanks! That really cleared things up for me.