0
저는 JSON 스키마와 Json.NET 스키마가 처음이에요. 스키마 검증을 수행하는 테스트 프로그램을 작성하기 위해 샘플을 따라 가봤습니다. 임의의 스키마와 무분별한 JSON 파일을 선택했지만 끝에있는 IsValid() 호출은 True를 반환합니다. 내가 놓친 게 있니? 감사.임의의 문서에 대해 스키마 유효성 검사가 통과 되었습니까?
는static void SchemaTest3()
{
string schemaJson = @"{
'description': 'A person',
'type': 'object',
'properties': {
'name': {'type':'string'},
'hobbies': {
'type': 'array',
'items': {'type':'string'}
}
}
}";
JSchema schema = JSchema.Parse(schemaJson);
IList<string> errorMessages;
JToken jToken = JToken.Parse(@"{
'@Id': 1,
'Email': '[email protected]',
'Active': true,
'CreatedDate': '2013-01-20T00:00:00Z',
'Roles': [
'User',
'Admin'
],
'Team': {
'@Id': 2,
'Name': 'Software Developers',
'Description': 'Creators of fine software products and services.'
}
}");
bool isValid = jToken.IsValid(schema, out errorMessages);
Console.Write(isValid);
}