我正在提交此JSON字符串:
{
"companyName" : "Goog"
}
架构是:
{
"companyName": {
"type":[ "string", "null" ],
"description": "Companies list",
"required":false ,
"maxLength": 256,
"enum": [ "Google", "Apple" , null ]
}
}
我使用Newtonsoft.Json验证器函数 IsValid
JObject jobj= _jsonParser.ToJSonObject(jsonString);
IList<string> errMessages;
var valid = jobj.IsValid(jsonSchema, out errMessages);
当我验证时,我会重复两次相同的错误消息:
Value "Goog" is not defined in enum. Line 34, position 35., Value "Goog" is not defined in enum. Line 34, position 35.
我在做什么有问题吗?或者这是JSON验证器的问题吗?
答案 0 :(得分:0)
对于我收到的错误消息,我把它放在一个列表中并调用distinct()
errMessages.Distinct().ToList()