Integrating Json into report as string instead of file

Stimulsoft Reports.JAVA discussion
Post Reply
mke_imp
Posts: 9
Joined: Tue Nov 29, 2016 9:15 am

Integrating Json into report as string instead of file

Post by mke_imp »

I have a running example of integrating a Json as a StiJsonDatabase with the following code.

Code: Select all

        
StiReport report = StiSerializeManager.deserializeReport(new File("report/Selection.mrt"));
StiJsonDatabase jsonDb = new StiJsonDatabase("Data", "report/data.json");
StiDatabaseCollection coll = new StiDatabaseCollection();
coll.add(jsonDb);
report.dictionary.setDatabases(coll);
report.setJsonReport(true);
report.render();
Now I have the problem, that I want to integrate the json as a string into the report instead of a file, which I have been able to get running with the following code:

Code: Select all

StiReport report = StiSerializeManager.deserializeReport(new File("report/Selection.mrt"));
DataSet ds = StiJsonToDataSetConverter.detDataTable(jsonString);
report.dictionary.setCacheDataSet(ds);
report.setJsonReport(true);
report.render();
This does work, but I get a lot of warnings (one for each table in the data) that read 'Element named 'TableXyz1' missing.
Is there a better way to integrate a json-String as data?

Thanks a lot in advance
Vadim
Posts: 362
Joined: Tue Apr 23, 2013 11:23 am

Re: Integrating Json into report as string instead of file

Post by Vadim »

Hello.
You can integrate JSON data this way:

Code: Select all

jsonDb.setEmbeddedData(StiIOUtil.toString(new FileInputStream("C:/84/1.json")));
Post Reply