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
How I can use a JSON file to create a StiJsonDatabase
-
- Posts: 4
- Joined: Mon Dec 19, 2016 11:20 am
Re: How I can use a JSON file to create a StiJsonDatabase
Hello.
The JSON file & code is ok.
It's something wrong with your template .mrt file.
You can send us it for analyze.
The JSON file & code is ok.
It's something wrong with your template .mrt file.
You can send us it for analyze.
-
- Posts: 4
- Joined: Mon Dec 19, 2016 11:20 am
Re: How I can use a JSON file to create a StiJsonDatabase
got it.
new StiJsonDatabase("Data", new File("Data/auDemo2.json"));
There the "Data" , first parameter of the StiJsonDatabase method , should same with the datasource's name that named in the designer.
thanks!
new StiJsonDatabase("Data", new File("Data/auDemo2.json"));
There the "Data" , first parameter of the StiJsonDatabase method , should same with the datasource's name that named in the designer.
thanks!
Re: How I can use a JSON file to create a StiJsonDatabase
Hello.
We are always glad to help you.
Let us know if you need our help.
Thank you.
We are always glad to help you.
Let us know if you need our help.
Thank you.