Click or drag to resize
Json.NET

Save JSON Schema to a file

 

This sample saves a JsonSchema to a file.

Caution note Caution

Obsolete. JSON Schema validation has been moved to its own package. See https://www.newtonsoft.com/jsonschema for more details.

Sample
Usage
JsonSchema schema = new JsonSchema
{
    Type = JsonSchemaType.Object
};

// serialize JsonSchema to a string and then write string to a file
File.WriteAllText(@"c:\schema.json", schema.ToString());

// serialize JsonSchema directly to a file
using (StreamWriter file = File.CreateText(@"c:\schema.json"))
using (JsonTextWriter writer = new JsonTextWriter(file))
{
    schema.WriteTo(writer);
}