JsonSchemaNode() Constructor

Initializes a new instance of the JsonSchemaNode class.

Namespace: DevExpress.DataAccess.Json

Assembly: DevExpress.DataAccess.v20.2.dll

Declaration

[Browsable(false)]
public JsonSchemaNode()
<Browsable(False)>
Public Sub New

Remarks

Use this constructor to create the data source schema's root node:

  • The root node does not define a JSON object's node.
  • The root node has child nodes that define the JSON object's nodes.

The following code sample demonstrates a root node.

using DevExpress.DataAccess.Json;
        // ...
        public static JsonDataSource CreateDataSourceFromWeb() {
            var jsonDataSource = new JsonDataSource();
            // Specify the endpoint.
            jsonDataSource.JsonSource = new UriJsonSource(new Uri("http://northwind.servicestack.net/customers.json"));
            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("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))),
                new JsonSchemaNode(new JsonNode("Address", false, JsonNodeType.Property, typeof(string)))
            });

            root.AddChildren(customers);
            jsonDataSource.Schema = root;
            // Populate the data source with data.
            jsonDataSource.Fill();
            return jsonDataSource;
        }
See Also