All docs
V20.2
20.2
20.1
19.2
The page you are viewing does not exist in version 19.2. This link will take you to the root page.
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

JsonDataSource.LoadSchema(Type) Method

Creates the data source schema from the provided type.

Namespace: DevExpress.DataAccess.Json

Assembly: DevExpress.DataAccess.v20.2.dll

Declaration

public JsonSchemaNode LoadSchema(
    Type type
)
Public Function LoadSchema(
    type As Type
) As JsonSchemaNode

Parameters

Name Type Description
type Type

The type used to create the schema.

Returns

Type Description
JsonSchemaNode

The created data source schema.

Remarks

Use this method to specify a JSON data source schema without the need to read data from the endpoint. This method creates a data source field for each public property from the specified type parameter. Private, protected, and internal properties are ignored. A property's type is used to specify the field type.

NOTE

Members of the specified type should not be of the same type (or an inherited type) to avoid the stack overflow exception.

Example

The code sample below creates a new JSON data source and uses the JsonDataObject and Customer types to specify the data source schema.

Data Source Schema

using DevExpress.DataAccess.Json;
// ...
public class JsonDataObject {
    public Customer[] Customers { get; set; }
}
public class Customer {
    // A public property is added to the data source's field list.
    public string CompanyName { get; set; }
    // A private property is not added to the data source's field list.
    private string ContactName { get; set; }
}
// ...
JsonDataSource dataSource = new JsonDataSource();
dataSource.JsonSource = new UriJsonSource() {
    Uri = new Uri(@"https://raw.githubusercontent.com/DevExpress-Examples/DataSources/master/JSON/customers.json")
};
// Create the data source schema from the JsonDataObject type.
dataSource.Schema = dataSource.LoadSchema(typeof(JsonDataObject));
See Also