JsonDataSource

JsonDataSource(string)

Creates a new data source with data from a JSON file using default options for parsing JSON data.

public JsonDataSource(string jsonPath)
ParameterTypeDescription
jsonPathStringThe path to the JSON file to be used as the data source.

See Also


JsonDataSource(Stream)

Creates a new data source with data from a JSON stream using default options for parsing JSON data.

public JsonDataSource(Stream jsonStream)
ParameterTypeDescription
jsonStreamStreamThe stream of JSON data to be used as the data source.

See Also


JsonDataSource(string, JsonDataLoadOptions)

Creates a new data source with data from a JSON file using the specified options for parsing JSON data.

public JsonDataSource(string jsonPath, JsonDataLoadOptions options)
ParameterTypeDescription
jsonPathStringThe path to the JSON file to be used as the data source.
optionsJsonDataLoadOptionsOptions for parsing JSON data.

Examples

Shows how to use JSON as a data source (string).

Document doc = new Document(MyDir + "Reporting engine template - JSON data destination.docx");

JsonDataLoadOptions options = new JsonDataLoadOptions
{
    ExactDateTimeParseFormats = new List<string> {"MM/dd/yyyy", "MM.d.yy", "MM d yy"},
    AlwaysGenerateRootObject = true,
    PreserveSpaces = true,
    SimpleValueParseMode = JsonSimpleValueParseMode.Loose
};

JsonDataSource dataSource = new JsonDataSource(MyDir + "List of people.json", options);
BuildReport(doc, dataSource, "persons");

doc.Save(ArtifactsDir + "ReportingEngine.JsonDataString.docx");

See Also


JsonDataSource(Stream, JsonDataLoadOptions)

Creates a new data source with data from a JSON stream using the specified options for parsing JSON data.

public JsonDataSource(Stream jsonStream, JsonDataLoadOptions options)
ParameterTypeDescription
jsonStreamStreamThe stream of JSON data to be used as the data source.
optionsJsonDataLoadOptionsOptions for parsing JSON data.

Examples

Shows how to use JSON as a data source (stream).

Document doc = new Document(MyDir + "Reporting engine template - JSON data destination.docx");

JsonDataLoadOptions options = new JsonDataLoadOptions
{
    ExactDateTimeParseFormats = new List<string> {"MM/dd/yyyy", "MM.d.yy", "MM d yy"}
};

using (FileStream stream = File.OpenRead(MyDir + "List of people.json"))
{
    JsonDataSource dataSource = new JsonDataSource(stream, options);
    BuildReport(doc, dataSource, "persons");
}

doc.Save(ArtifactsDir + "ReportingEngine.JsonDataStream.docx");

See Also