UriJsonSource Class
Associates a JsonDataSource object with JSON data retrieved from a web service endpoint or a text file.
Namespace: DevExpress.DataAccess.Json
Assembly: DevExpress.DataAccess.v20.2.dll
NuGet Packages: DevExpress.DataAccess, DevExpress.WindowsDesktop.DataAccess
Declaration
Remarks
You can add path parameters, query parameters, or header parameters to the UriJsonSource to customize requests to a JSON web service endpoint.
- A path parameter adds a path element to a JSON endpoint’s Uri.
- A query parameter specifies an HTTP request parameter that is passed to a JSON endpoint.
- A header parameter adds a custom HTTP header to JSON endpoint requests.
The following example demonstrates how to populate the JsonDataSource with data from a web-service endpoint.
using DevExpress.DataAccess.Json;
// ...
public static JsonDataSource CreateDataSourceFromWeb() {
var jsonDataSource = new JsonDataSource();
// Specify the endpoint.
jsonDataSource.JsonSource = new UriJsonSource(new Uri("https://northwind.netcore.io/customers.json"));
// Populate the data source with data.
jsonDataSource.Fill();
return jsonDataSource;
}
The following example demonstrates how to populate the JsonDataSource with JSON data from a file.
using DevExpress.DataAccess.Json;
// ...
public static JsonDataSource CreateDataSourceFromFile() {
var jsonDataSource = new JsonDataSource();
// Specify the JSON file name.
Uri fileUri = new Uri("customers.json", UriKind.RelativeOrAbsolute);
jsonDataSource.JsonSource = new UriJsonSource(fileUri);
// Populate the data source with data.
jsonDataSource.Fill();
return jsonDataSource;
}
Inheritance
Object
JsonSourceBase
UriJsonSource
See Also