Table of Contents

Class JsonConnectorExtensions

Namespace
Datafication.Extensions.Connectors.JsonConnector
Assembly
Datafication.JsonConnector.dll

Provides extension methods for loading JSON data into DataBlock instances.

public static class JsonConnectorExtensions
Inheritance
object
JsonConnectorExtensions

Examples

// Load JSON from a local file
var data = await DataBlock.Connector.LoadJsonAsync("data/employees.json");

// Load JSON from a remote URL
var remoteData = await DataBlock.Connector.LoadJsonAsync("https://api.example.com/users");

Remarks

These extension methods provide a convenient shorthand API for loading JSON data from local files or remote URLs. They are accessed via the Connector property.

Methods

LoadJson(ConnectorExtensions, JsonConnectorConfiguration)

Synchronously loads JSON data using the specified configuration into a DataBlock.

public static DataBlock LoadJson(this ConnectorExtensions connectorExtensions, JsonConnectorConfiguration configuration)

Parameters

connectorExtensions ConnectorExtensions

The connector extensions instance.

configuration JsonConnectorConfiguration

The JSON connector configuration specifying the source and options.

Returns

DataBlock

The loaded DataBlock.

Examples

var config = new JsonConnectorConfiguration
{
    Source = new Uri("file:///data/employees.json"),
    ErrorHandler = ex => Console.WriteLine($"Error: {ex.Message}")
};
var employees = DataBlock.Connector.LoadJson(config);

Exceptions

ArgumentNullException

Thrown when configuration is null.

ArgumentException

Thrown when configuration validation fails.

LoadJson(ConnectorExtensions, string)

Synchronously loads JSON data from the specified source into a DataBlock.

public static DataBlock LoadJson(this ConnectorExtensions connectorExtensions, string source)

Parameters

connectorExtensions ConnectorExtensions

The connector extensions instance.

source string

The path or URL to the JSON data source. Can be a local file path or HTTP/HTTPS URL.

Returns

DataBlock

The loaded DataBlock.

Examples

var employees = DataBlock.Connector.LoadJson("data/employees.json");
Console.WriteLine($"Loaded {employees.RowCount} employees");

Exceptions

ArgumentNullException

Thrown when source is null or empty.

FileNotFoundException

Thrown when a local file source does not exist.

LoadJsonAsync(ConnectorExtensions, JsonConnectorConfiguration)

Asynchronously loads JSON data using the specified configuration into a DataBlock.

public static Task<DataBlock> LoadJsonAsync(this ConnectorExtensions connectorExtensions, JsonConnectorConfiguration configuration)

Parameters

connectorExtensions ConnectorExtensions

The connector extensions instance.

configuration JsonConnectorConfiguration

The JSON connector configuration specifying the source and options.

Returns

Task<DataBlock>

A task that represents the asynchronous operation. The task result contains the loaded DataBlock.

Examples

var config = new JsonConnectorConfiguration
{
    Source = new Uri("file:///data/employees.json"),
    ErrorHandler = ex => Console.WriteLine($"Error: {ex.Message}")
};
var employees = await DataBlock.Connector.LoadJsonAsync(config);

Exceptions

ArgumentNullException

Thrown when configuration is null.

ArgumentException

Thrown when configuration validation fails.

LoadJsonAsync(ConnectorExtensions, string)

Asynchronously loads JSON data from the specified source into a DataBlock.

public static Task<DataBlock> LoadJsonAsync(this ConnectorExtensions connectorExtensions, string source)

Parameters

connectorExtensions ConnectorExtensions

The connector extensions instance.

source string

The path or URL to the JSON data source. Can be a local file path or HTTP/HTTPS URL.

Returns

Task<DataBlock>

A task that represents the asynchronous operation. The task result contains the loaded DataBlock.

Examples

var employees = await DataBlock.Connector.LoadJsonAsync("data/employees.json");
Console.WriteLine($"Loaded {employees.RowCount} employees");

Exceptions

ArgumentNullException

Thrown when source is null or empty.

FileNotFoundException

Thrown when a local file source does not exist.