How I can use a JSON file to create a StiJsonDatabase
Posted: Mon Dec 19, 2016 12:06 pm
hello!
I have read the topic 'Example of rendering a report with Java and Json?' viewtopic.php?f=19&t=54471
And I think the following codes should work.
report = StiSerializeManager.deserializeReport(new File("Data/AuDemo.mrt"));
File file = new File("Data/auDemo2.json");
StiJsonDatabase jsonDb = new StiJsonDatabase("Data", new File("Data/auDemo2.json"));
System.out.println(jsonDb.toString());
jsonDb.getJSONObject().keys().forEachRemaining( obj -> {
System.out.println(obj);
});
StiDatabaseCollection coll = new StiDatabaseCollection();
coll.add(jsonDb);
report.dictionary.setDatabases(coll);
report.setJsonReport(true);
report.render();
the json file like this
{
"Offers": [
{
"id": "5",
"subId": "5_1",
"name": "Offer 1",
"location": "City"
}
],
"Students": [
{
"id": "5",
"firstName": "Anne-Marie",
"lastName": "Abdula",
"schoolclassShort": "3a"
}
],
"Period": [{
"dateFrom": "22.08.2016",
"dateTo": "31.10.2016"
}]
}
but I got message as following , and cannot get anything in the report .
十二月 19, 2016 7:52:05 下午 com.stimulsoft.lib.utils.StiCollectionsUtil getElement
警告: Element named 'auDemo' missing
十二月 19, 2016 7:52:05 下午 com.stimulsoft.lib.utils.StiCollectionsUtil getElement
警告: Element named 'auDemo' missing
十二月 19, 2016 7:52:05 下午 com.stimulsoft.lib.utils.StiCollectionsUtil getElement
警告: Element named 'auDemo' missing
十二月 19, 2016 7:52:05 下午 com.stimulsoft.lib.utils.StiCollectionsUtil getElement
警告: Element named 'auDemo' missing
十二月 19, 2016 7:52:05 下午 com.stimulsoft.lib.utils.StiCollectionsUtil getElement
警告: Element named 'auDemo' missing
十二月 19, 2016 7:52:05 下午 com.stimulsoft.lib.utils.StiCollectionsUtil getElement
警告: Element named 'auDemo' missing
十二月 19, 2016 7:52:05 下午 com.stimulsoft.report.engine.parser.StiParser ParseTextValue
警告: Parser error: Syntax error - unprocessed lexemes remain, , , ,
My env is
macOS Sierra 10.12.1
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
how to do that the StiJsonDatabase can be cteated OK ?
thanks
I have read the topic 'Example of rendering a report with Java and Json?' viewtopic.php?f=19&t=54471
And I think the following codes should work.
report = StiSerializeManager.deserializeReport(new File("Data/AuDemo.mrt"));
File file = new File("Data/auDemo2.json");
StiJsonDatabase jsonDb = new StiJsonDatabase("Data", new File("Data/auDemo2.json"));
System.out.println(jsonDb.toString());
jsonDb.getJSONObject().keys().forEachRemaining( obj -> {
System.out.println(obj);
});
StiDatabaseCollection coll = new StiDatabaseCollection();
coll.add(jsonDb);
report.dictionary.setDatabases(coll);
report.setJsonReport(true);
report.render();
the json file like this
{
"Offers": [
{
"id": "5",
"subId": "5_1",
"name": "Offer 1",
"location": "City"
}
],
"Students": [
{
"id": "5",
"firstName": "Anne-Marie",
"lastName": "Abdula",
"schoolclassShort": "3a"
}
],
"Period": [{
"dateFrom": "22.08.2016",
"dateTo": "31.10.2016"
}]
}
but I got message as following , and cannot get anything in the report .
十二月 19, 2016 7:52:05 下午 com.stimulsoft.lib.utils.StiCollectionsUtil getElement
警告: Element named 'auDemo' missing
十二月 19, 2016 7:52:05 下午 com.stimulsoft.lib.utils.StiCollectionsUtil getElement
警告: Element named 'auDemo' missing
十二月 19, 2016 7:52:05 下午 com.stimulsoft.lib.utils.StiCollectionsUtil getElement
警告: Element named 'auDemo' missing
十二月 19, 2016 7:52:05 下午 com.stimulsoft.lib.utils.StiCollectionsUtil getElement
警告: Element named 'auDemo' missing
十二月 19, 2016 7:52:05 下午 com.stimulsoft.lib.utils.StiCollectionsUtil getElement
警告: Element named 'auDemo' missing
十二月 19, 2016 7:52:05 下午 com.stimulsoft.lib.utils.StiCollectionsUtil getElement
警告: Element named 'auDemo' missing
十二月 19, 2016 7:52:05 下午 com.stimulsoft.report.engine.parser.StiParser ParseTextValue
警告: Parser error: Syntax error - unprocessed lexemes remain, , , ,
My env is
macOS Sierra 10.12.1
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
how to do that the StiJsonDatabase can be cteated OK ?
thanks