Files
Newtonsoft.Json/Src/Newtonsoft.Json.Tests/Documentation/Samples/Schema/JsonSchemaParse.cs
T
2013-10-20 15:08:39 +13:00

41 lines
1.0 KiB
C#

using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Schema;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Newtonsoft.Json.Tests.Documentation.Samples.Schema
{
public class JsonSchemaParse
{
public void Example()
{
#region Usage
string schemaJson = @"{
'description': 'A person',
'type': 'object',
'properties': {
'name': {'type':'string'},
'hobbies': {
'type': 'array',
'items': {'type':'string'}
}
}
}";
JsonSchema schema = JsonSchema.Parse(schemaJson);
Console.WriteLine(schema.Type);
// Object
foreach (var property in schema.Properties)
{
Console.WriteLine(property.Key + " - " + property.Value.Type);
}
// name - String
// hobbies - Array
#endregion
}
}
}