JSON data file
Hi! Im new to fast Report and i've been searching for this on the internet for a few days without success...
I made a report with a JSON connection. The connection only has a JSON Schema defined, the URL or JSON DATA is empty as I want to send the data froma generated file.
I can use the variables and access the fields inside the report as JSON schema is valid.
How can i set the JSON connection URL or data from c#. I dont want to create a new connection as its already saved in the file with its JSON Schema.
Thanks in advance!
This discussion has been closed.
Comments
I solved it replacing ConnectionString Json=; with my json base64 string!
Hello!
To ensure that a .frx template with a JsonDataSourceConnection retrieves the schema from a file during design time, whilst at runtime it fetches data from memory or another JSON source:
Register the connection type once when the application starts:
FastReport.Utils.RegisteredObjects.AddConnection(typeof(JsonDataSourceConnection));In the code, locate the existing JsonDataSourceConnection in `report.Dictionary.Connections` and update the `ConnectionString` using `JsonDataSourceConnectionStringBuilder` (by encoding the JSON string in Base64 or specifying a new JSON path), whilst retaining the same JSON structure:
var conn = report.Dictionary.Connections.OfType<JsonDataSourceConnection>().First(); conn.ConnectionString = $‘Json={Convert.ToBase64String(Encoding.UTF8.GetBytes(jsonString))}’;