Page 1 of 1

Updating JSON data source

Posted: Tue Jun 21, 2016 2:31 pm
by bnx2017
I have a WebAPI server which is returning a report just fine using code previously provided. However, I need to provide the JSON data source to it dynamically, and I cannot get the examples I have found on the forums to work for me. The example I found that seems ideal is this one:

Code: Select all

var dataSet = new Stimulsoft.System.Data.DataSet("invoice");
dataSet.readJson(reportdata);
report.regData(dataSet.dataSetName, "", dataSet);
However, there is no Stimulsoft.System.Data assembly on my computer. Is this not available in the web version? Why not?

I can get this example I found to compile, but I see that this object type is internal, and I am not sure how to get it to load the JSON data either.

Code: Select all

var dataSet = new Stimulsoft.Report.Dictionary.StiJsonDatabase("mydata", "");
This seems a basic requirement for a web server, so I hope that it is possible without resorting to files.

I look forward to learning how to do it properly. Thank you.

Re: Updating JSON data source

Posted: Wed Jun 22, 2016 12:41 pm
by HighAley
Hello.

Where did you get this code? It seems that this is JavaScript code.

Please, try to use next code if you need to register JSON data in the report.

Code: Select all

var ds = StiJsonToDataSetConverter.GetDataSetFromFile(jsonFilePath);
report.RegData(ds);
Thank you.

Re: Updating JSON data source

Posted: Wed Jun 22, 2016 12:53 pm
by bnx2017
Ah, that explains so much! I got it from the forum here by searching - didn't realise it was Javascript...

The code you suggest loads from a file again though, and I have the JSON in memory, obtained from a complex object creation. I'd like to load from string.

Okay, a quick test based on the intellisense and I have this working:

Code: Select all

report.Dictionary.Databases.Clear();
var ds = StiJsonToDataSetConverter.GetDataSet(jsonReport); // where jsonReport is string containing the JSON
report.RegData(ds);
Perfect, thank you!

Re: Updating JSON data source

Posted: Wed Jun 22, 2016 6:17 pm
by Alex K.
Hello,

Let us know if you need any additional help.

Thank you.