Click or drag to resize

Load JSON Schema from a file


This sample loads a JsonSchema from a file.

Caution note Caution

Obsolete. JSON Schema validation has been moved to its own package. See for more details.

// read file into a string and parse JsonSchema from the string
JsonSchema schema1 = JsonSchema.Parse(File.ReadAllText(@"c:\schema.json"));

// read JsonSchema directly from a file
using (StreamReader file = File.OpenText(@"c:\schema.json"))
using (JsonTextReader reader = new JsonTextReader(file))
    JsonSchema schema2 = JsonSchema.Read(reader);