JsonSimpleValueParseMode

JsonSimpleValueParseMode enumeration

指定加载 JSON 时解析 JSON 简单值(null、boolean、number、integer 和 string)的模式。 此模式不会影响日期时间值的解析。

public enum JsonSimpleValueParseMode

价值观

姓名价值描述
Loose0指定在解析 JSON 简单值的字符串表示形式时确定其类型的模式。 例如,在此模式下,JSON 代码片段“{prop:“123”}”中的“prop”类型被确定为整数。
Strict1指定从 JSON 符号本身确定 JSON 简单值类型的模式。 例如,在此模式下,JSON 代码片段“{prop:“123”}”中的“prop”类型被确定为字符串。

例子

展示如何使用 JSON 作为数据源(字符串)。

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");

也可以看看