Skip to main content

UriJsonSource.Uri Property

Gets or sets the System.Uri object that points to a URI or text file with JSON data.

Namespace: DevExpress.DataAccess.Json

Assembly: DevExpress.DataAccess.v23.2.dll

NuGet Packages: DevExpress.DataAccess, DevExpress.Win.PivotGrid, DevExpress.Win.TreeMap

Declaration

[DefaultValue(null)]
public Uri Uri { get; set; }

Property Value

Type Default Description
Uri null

Points to a Web-service endpoint or text file with JSON data.

Remarks

The following example demonstrates how to associate the JsonDataSource object with data from a web-service endpoint.

using DevExpress.DataAccess.Json;
using DevExpress.XtraReports.UI;
public static JsonDataSource CreateDataSourceFromWeb() {
    var jsonDataSource = new JsonDataSource();
    // Specify the endpoint.
    jsonDataSource.JsonSource = new UriJsonSource(
        new Uri("https://raw.githubusercontent.com/DevExpress-Examples/DataSources/master/JSON/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;
            // The schema is built, you do not have to call the Fill method to populate the Field List.
            // The Designer calls the Fill method automatically when a document is generated for preview.
            //jsonDataSource.Fill();
            return jsonDataSource;
        }

The following example demonstrates how to associate the JsonDataSource object with JSON data from a file.

using DevExpress.DataAccess.Json;
using DevExpress.XtraReports.UI;
public static JsonDataSource CreateDataSourceFromFile() {
    var jsonDataSource = new JsonDataSource();
    // Specify the JSON file name.
    Uri fileUri = new Uri("customers.json", UriKind.RelativeOrAbsolute);
    jsonDataSource.JsonSource = new UriJsonSource(fileUri);
    // Populate the data source with data.
    jsonDataSource.Fill();
    return jsonDataSource;
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Uri property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also