JsonDataLoadOptions

JsonDataLoadOptions class

Represents options for parsing JSON data.

To learn more, visit the LINQ Reporting Engine documentation article.

public class JsonDataLoadOptions

Constructors

NameDescription
JsonDataLoadOptions()Initializes a new instance of this class with default options.

Properties

NameDescription
AlwaysGenerateRootObject { get; set; }Gets or sets a flag indicating whether a generated data source will always contain an object for a JSON root element. If a JSON root element contains a single complex property, such an object is not created by default.
ExactDateTimeParseFormats { get; set; }Gets or sets exact formats for parsing JSON date-time values while loading JSON. The default is null.
PreserveSpaces { get; set; }Gets or sets a flag indicating whether leading and trailing spaces should be preserved when loading string values of JSON data.
SimpleValueParseMode { get; set; }Gets or sets a mode for parsing JSON simple values (null, boolean, number, integer, and string) while loading JSON. Such a mode does not affect parsing of date-time values. The default is Loose.

Remarks

An instance of this class can be passed into constructors of JsonDataSource.

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