Class SchemaAwareJsonDataProvider
- Namespace
- combit.Reporting.DataProviders
- Assembly
- combit.ListLabel31.CrossPlatform.SchemaAwareJsonDataProvider.dll
Provides JSON data handling with schema awareness, allowing for validation and structured processing.
public class SchemaAwareJsonDataProvider : JsonDataProvider, IDataProvider, ISerializable, ISupportsLogger
- Inheritance
-
SchemaAwareJsonDataProvider
- Implements
- Inherited Members
Examples
The following example demonstrates how to use the SchemaAwareJsonDataProvider to export a report to PDF:
// Create a SchemaAwareJsonDataProvider with JSON data.
SchemaAwareJsonDataProvider provider = new SchemaAwareJsonDataProvider(
@"C:\Data\customers.json",
new JsonDataProviderOptions());
// Set the schema location to validate and structure the JSON data.
provider.Schema = @"C:\Schemas\customers-schema.json";
// Optional: Configure table generation behavior.
provider.UseUniqueTables = true; // Generate unique table for each subschema occurrence
// Create a ListLabel reporting engine instance and assign the provider as the data source.
using ListLabel listLabel = new ListLabel();
listLabel.DataSource = provider;
// Configure export settings to generate a PDF.
ExportConfiguration exportConfiguration = new ExportConfiguration(LlExportTarget.Pdf, exportFilePath, projectFilePath);
exportConfiguration.ShowResult = true;
// Export the report to PDF.
listLabel.Export(exportConfiguration);
Remarks
The SchemaAwareJsonDataProvider class extends JsonDataProvider to add support for JSON schema definitions. It validates and processes JSON data according to a provided schema, automatically inferring table structures, column types, and relationships from the schema definition. The provider supports both file paths and URLs for loading schemas and can be configured to generate unique tables for each subschema occurrence or reuse tables when the same subschema appears multiple times. Properties must be defined under the "properties" key in single schema format; "AnyOf" schemas are not currently supported.
Constructors
SchemaAwareJsonDataProvider(TextReader)
Initializes a new instance of the SchemaAwareJsonDataProvider class using a TextReader.
public SchemaAwareJsonDataProvider(TextReader reader)
Parameters
readerTextReaderThe text reader containing JSON data.
SchemaAwareJsonDataProvider(string)
Initializes a new instance of the SchemaAwareJsonDataProvider class using a JSON string.
public SchemaAwareJsonDataProvider(string json)
Parameters
jsonstringThe JSON string to parse.
SchemaAwareJsonDataProvider(string, JsonDataProviderOptions)
Initializes a new instance of the SchemaAwareJsonDataProvider class using a file path or URL.
public SchemaAwareJsonDataProvider(string filePathOrUrl, JsonDataProviderOptions options)
Parameters
filePathOrUrlstringThe file path or URL to the JSON data.
optionsJsonDataProviderOptionsThe JSON data provider options.
Properties
Schema
Gets or sets the file path or URL that points to a JSON schema definition. The schema is resolved using the provided SchemaFileProvider. If SchemaFileProvider is not set, the default FileProvider will be used.
- Properties must be directly provided under the "properties" key (single schema format). - "AnyOf" schemas are not currently supported. - The RootTableName is set to the schema title. - The ArrayValueName is set to the array item name if the data is an array.
public string Schema { get; set; }
Property Value
- See Also
SchemaFileProvider
Gets or sets the NetworkFileProvider used for resolving the Schema. If not set, FileProvider will be used as a fallback.
public NetworkFileProvider SchemaFileProvider { get; set; }
Property Value
UseUniqueTables
Gets or sets a value indicating whether to generate a unique table for each subschema.
If false, a single table will be generated for each subschema, even if used multiple times in the schema.
public bool UseUniqueTables { get; set; }