Using Json as Datasource

Stimulsoft Reports.NET discussion
Post Reply
User avatar
ProIT
Posts: 28
Joined: Thu Oct 17, 2013 8:10 am
Location: Muttenz

Using Json as Datasource

Post by ProIT »

Hi there

I have a json file as a datasource for a report. Unfortunately I am not able to load the report with the json datasource (don't know where to start). Is there a sample of how to create a report with a json datasource (and change the path to the json-file at runtime)? Or do I need to load the json file into an dataset / list?

Thank you for your support!
Mike
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Using Json as Datasource

Post by HighAley »

Hello.

You could use the StiJsonToDataSetConverter class to load JSON from file and register the DataSet that you get.

Code: Select all

var ds = StiJsonToDataSetConverter.GetDataSetFromFile(@"d:\server.en.json");
report.RegData(ds);
If you need to change path to the JSON file you could use next code:

Code: Select all

(report.Dictionary.Databases[0] as StiJsonDatabase).PathData = yourPath;
Thank you.
User avatar
ProIT
Posts: 28
Joined: Thu Oct 17, 2013 8:10 am
Location: Muttenz

Re: Using Json as Datasource

Post by ProIT »

Hi

Works perfectly!

Thank you very much!
Mike
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Using Json as Datasource

Post by HighAley »

Hello, Mike.

We are always glad to help you.
Let us know if you need any additional help.

Thank you.
Post Reply