Page 1 of 1

Integrating Json into report as string instead of file

Posted: Tue Dec 20, 2016 7:54 am
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

Re: Integrating Json into report as string instead of file

Posted: Wed Dec 21, 2016 6:45 am
by Vadim
Hello.
You can integrate JSON data this way:

Code: Select all

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