Skip to main content
A newer version of this page is available. .

JsonSchemaNode(JsonNode) Constructor

Initializes a new instance of the JsonSchemaNode class.

Namespace: DevExpress.DataAccess.Json

Assembly: DevExpress.DataAccess.v19.1.dll

Declaration

public JsonSchemaNode(
    JsonNode value
)

Parameters

Name Type Description
value JsonNode

Defines the created JSON schema node.

Remarks

The JsonNode object passed as the constructor’s parameter is assigned to the Value property and used to specify the JsonSchemaNode’s properties.

Example:

using DevExpress.DataAccess.Json;
using DevExpress.XtraReports.UI;
//...
private JsonDataSource CreateDataSourceFromWeb()
{
    var jsonDataSource = new JsonDataSource();
    //Specify the data source location
    jsonDataSource.JsonSource = new UriJsonSource(new Uri("http://northwind.servicestack.net/customers.json"));

    // Define the Customers node's scheme to retrieve only required child nodes and properties
    var customers = new JsonSchemaNode() {NodeType=JsonNodeType.Array, Name="Customers", Selected=true };
    customers.AddChildren(new[] {
        new JsonSchemaNode(new JsonNode("CustomerID", true, JsonNodeType.Property, typeof(string))) { DisplayName = "Customer ID" },
        new JsonSchemaNode() {
            Name =  "CompanyName",
            Selected = true,
            NodeType = JsonNodeType.Property,
            Type = typeof(string)
        },
        new JsonSchemaNode(new JsonNode("ContactTitle", true, JsonNodeType.Property, typeof(string))),
        //Set the JsonNode.Selected to false not to retrieve the Address field
        new JsonSchemaNode(new JsonNode("Address", false, JsonNodeType.Property, typeof(string)))
    });


    // Create a root schema node
    var root = new JsonSchemaNode();
    root.NodeType = JsonNodeType.Object;
    // Add the defined Customers schema node to the root node
    root.AddChildren(customers);
    // Specify the JsonDataSource's Scheme property to retrieve data only from the Customers node
    jsonDataSource.Schema = root;

    // Retrieve data from the JSON data source
    jsonDataSource.Fill();
    return jsonDataSource;
}
See Also