AlwaysGenerateRootObject

JsonDataLoadOptions.AlwaysGenerateRootObject property

Oluşturulan bir veri kaynağının her zaman bir JSON root öğesi için bir nesne içerip içermeyeceğini belirten bir bayrak alır veya ayarlar. Bir JSON kök öğesi tek bir karmaşık özellik içeriyorsa, böyle bir nesne varsayılan olarak oluşturulmaz.

public bool AlwaysGenerateRootObject { get; set; }

Notlar

Varsayılan değer:YANLIŞ .

Örnekler

JSON’un veri kaynağı (dize) olarak nasıl kullanılacağını gösterir.

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

Ayrıca bakınız