JSON as datasource question
Hey friends, I'm working on a POC using FastReports for the first time and I'd like some help, if it's possible:
I created a sample API which works basically with two parameters in the request's body, as you can see below:
{ "documentName": "test.frx", "parameters": { } }
The documentName field is static, but the object parameters has its own properties and the request data should be reflected in the report. Once I call the API to generate the report, it's created only with the example data of the JSON that I used to generate the schema in the datasource.
Here's how my code is today:
RegisteredObjects.AddConnection(typeof(JsonDataConnection));
var report = new Report();
JsonDataConnection connection = new JsonDataConnection();
connection.JsonData = document.Parameters.ToString();
connection.CreateAllTables();
report.Dictionary.Connections.Add(connection);
report.RegisterData(connection.DataSet);
report.Load(new MemoryStream(frxFile));
report.Prepare();
Following the datasource as JSON (not JSON database) and the report:

Once the request is sent and the report is generated, it cames with the property "name" always with the value "Nicolas" and not with the data from the request. Anyone has any ideas on that?
Thanks in advance!
Look this https://github.com/FastReports/FastReport/issues/281
Hello,
i am trying to make a working example of registering Json data, using similiar code as @nicolasbcp. But I am working on an opensource project and have to use the open source version of Fast Reports (FastReport.OpenSource 2021.4. )
The code is not geting compiled, It gives me an error :"The type 'type' is defined in an assembly that is not referenced. You must add a reference to assembly 'FastReport, version 2021.4.0.0".
Do I have to use different approach or method when working with open source version of FastReport?
Hello!
This implementation will work:
var builder = new JsonDataSourceConnectionStringBuilder();
builder.Json = "[]";
JsonDataSourceConnection conn = new JsonDataSourceConnection();
conn.ConnectionString = builder.ToString();
report.Dictionary.Connections.Add(conn);
conn.CreateAllTables();
Best regards Marat