A newer version of this page is available. Switch to the current version.

JsonSchemaNode Class

Defines a node and its hierarchy in the JsonDataSource‘s schema.

Namespace: DevExpress.DataAccess.Json

Assembly: DevExpress.DataAccess.v19.1.dll

Declaration

public class JsonSchemaNode :
    Node<JsonNode>,
    INotifyPropertyChanged

The following members accept/return JsonSchemaNode objects:

Library Related API Members
Cross-Platform Class Library DataSourceModel.JsonSchema
IJsonDataSourceModel.JsonSchema
JsonDataSource.Schema
JsonDataSourceModel.JsonSchema
Reporting XtraReportModel.JsonSchema

Remarks

A JsonDataSource‘s schema is a collection of JsonNode items. The JsonSchemaNode class specifies a node as part of the schema’s hierarchy:

  • The Parent property specifies the node’s immediate parent.
  • The GetParents() method returns a collection of parent nodes up to the schema’s root level.
  • The Children property stores a collection of the node’s children. The AddChildren(Node<T>[]) method appends nodes to the Children collection.
  • The AbandonChildren() method removes all children from the node.
  • The Selected property specifies whether to allow users to select the node or its children as data source fields.
  • The Value property contains a JsonNode class instance that defines the node’s additional properties.

You can specify a hierarchy of JsonSchemaNode in the JsonDataSource.Schema collection before you call the JsonDataSource.Fill method. If you do not specify the schema, JsonDataSource.Fill creates the data source schema and populates the data source with the data.

NOTE

Set JsonDataSource.Schema to null before you call JsonDataSource.Fill to discard the previous schema changes.

Example

The code sample below defines the JSON data source schema that consists of the Customer ID and CompanyName fields.

using DevExpress.DataAccess.Json;
using DevExpress.XtraReports.UI;
// ...
// Define the data source schema.
var root = new JsonSchemaNode();
root.NodeType = JsonNodeType.Object;
var customers = new JsonSchemaNode() { NodeType=JsonNodeType.Array, Name="Customers", Selected=true};
customers.AddChildren(new[] {
    new JsonSchemaNode(new JsonNode("ID", true, JsonNodeType.Property, typeof(string))) { DisplayName="Customer ID"},
    new JsonSchemaNode() { Name="CompanyName", Selected=true, NodeType=JsonNodeType.Property, Type=typeof(string)},
});
root.AddChildren(customers);

Inheritance

Object
Node<JsonNode>
JsonSchemaNode
See Also