PreserveSpaces

JsonDataLoadOptions.PreserveSpaces property

获取或设置一个标志,指示在加载 JSON 数据的字符串值时是否应保留前导和尾随空格。

public bool PreserveSpaces { get; set; }

评论

默认值为错误的.

例子

展示如何使用 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");

也可以看看