JsonSchemaNode Class
Defines a node and its hierarchy in the JsonDataSource‘s schema.
Namespace: DevExpress.DataAccess.Json
Assembly: DevExpress.DataAccess.v24.1.dll
NuGet Packages: DevExpress.DataAccess, DevExpress.Win.PivotGrid, DevExpress.Win.TreeMap
Declaration
[TypeConverter(typeof(JsonSchemaNode.JsonSchemaNodeTypeConverter))]
public class JsonSchemaNode :
Node<JsonNode>,
INotifyPropertyChanged
Remarks
A JsonDataSource‘s schema is a JsonSchemaNode class instance that represents the schema’s root node. The root node’s JsonSchemaNode.Children property contains a collection of JsonSchemaNode class instances that represent child nodes.
The following properties specify a schema node:
- 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;
// ...
// 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);