Updating JSON data source

Stimulsoft Reports.WEB discussion
Post Reply
bnx2017
Posts: 6
Joined: Tue Jun 21, 2016 2:22 pm

Updating JSON data source

Post 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.
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Updating JSON data source

Post 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.
bnx2017
Posts: 6
Joined: Tue Jun 21, 2016 2:22 pm

Re: Updating JSON data source

Post 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!
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Updating JSON data source

Post by Alex K. »

Hello,

Let us know if you need any additional help.

Thank you.
Post Reply