svoenix Posted January 13, 2014 Share Posted January 13, 2014 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)? Link to comment Share on other sites More sharing options...
wid.kencono Posted February 11, 2014 Share Posted February 11, 2014 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. Link to comment Share on other sites More sharing options...
dsrini.open Posted May 29, 2014 Share Posted May 29, 2014 I am not sure about file input - what I've done is String input which is a json -def jsonBytes = ((String) jsonData ).getBytes()streamForReportSource = new ByteArrayInputStream(jsonBytes);dataSource = new JsonDataSource(streamForReportSource, _defaultJSONSelectExpression)reportDef.jasperPrinter = JasperFillManager.fillReport(reportDef.getReport().inputStream, reportDef.parameters, dataSource)[/code]reportDef is nothing but JasperReportDef in grails- jasper plugin. One doesn't have to use this though.This one works perfect. Link to comment Share on other sites More sharing options...
narcism Posted June 17, 2014 Share Posted June 17, 2014 Could you post your JsonExample.jrxml? Link to comment Share on other sites More sharing options...
dwalton_2 Posted July 27, 2015 Share Posted July 27, 2015 What is "_defaultJSONSelectExpression"? I was having the same problem and switched to using the InputStream and am still getting no data in my report. Link to comment Share on other sites More sharing options...
narcism Posted July 28, 2015 Share Posted July 28, 2015 Have a look at the JSON DataSource sample: http://jasperreports.sourceforge.net/sample.reference/jsondatasource/index.html#jsondatasource Link to comment Share on other sites More sharing options...
dwalton_2 Posted July 28, 2015 Share Posted July 28, 2015 Thanks! That really cleared things up for me. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now