Я использую схему Json.NET для создания схемы из модели.Я в порядке при проверке:
using Newtonsoft.Json;
namespace HomeAddressSearch
{
public class Properties
{
[Required]
[JsonProperty(PropertyName = "civic_number")]
public string CivicNumber { get; set; }
[JsonProperty(PropertyName = "address")]
public string Address { get; set; }
[JsonProperty(PropertyName = "postal_code")]
public string PostalCode { get; set; }
[JsonProperty(PropertyName = "city_name")]
public string CityName { get; set; }
}
}
Я использую следующее и передаю JSON для проверки в выходную схему:
JSchemaGenerator generator = new JSchemaGenerator();
JSchema outputSchema = generator.Generate(typeof(Properties));
Я не знаю, что делать, когда я хочудля проверки JSON на модели Место, включающее модель Свойства:
namespace HomeAddressSearch
{
public class Place
{
public Place()
{
Properties = new Properties();
PlaceType = new List<string>();
}
[Required]
public string Id { get; set; }
[JsonProperty(PropertyName = "text")]
public string Text { get; set; }
[JsonProperty(PropertyName = "place_type")]
public List<string> PlaceType { get; set; }
[JsonProperty(PropertyName = "properties")]
public Properties Properties { get; set; }
}
}