C# 针对Xunit中JSon模式抛出数组异常错误的验证
我试图根据c代码验证我的json,但它抛出数组例外错误 JSON模式:C# 针对Xunit中JSon模式抛出数组异常错误的验证,c#,json,xunit,C#,Json,Xunit,我试图根据c代码验证我的json,但它抛出数组例外错误 JSON模式: "OrganisationIdentifier": { "type": "object", "additionalProperties": false, "properties": { "value": { "type&qu
"OrganisationIdentifier": {
"type": "object",
"additionalProperties": false,
"properties": {
"value": {
"type": "string"
},
"type": {
"enum": [
"Cdb",
"Ods",
"OrgId"
]
}
}
},
"Organisation": {
"type": "object",
"additionalProperties": false,
"required": [
"identifier",
"name"
],
"properties": {
"identifier": {
"type": "array",
"items": {
"$ref": "#/definitions/OrganisationIdentifier"
}
},
"name": {
"type": "string"
},
}
}
我的代码生成的json值如下
"organisation":{
"identifier":{
"items":[
{
"cdb":51,
"ods":"01",
"OrgId":45
}
]
},
"name":"Test"
}
我用来生成上述值的c代码如下
organisation = new
{
identifier = new
{
items = new[]
{
new
{
cdb = _currentUser.Cdb,
ods = _currentUser.NationalPracticeCode,
OrgId = _currentUser.OrganisationId
}
}
},
name = "Test"
}
我收到的错误是
Xunit.Sdk.XunitException: Expected collection to be empty because expected no validation errors, but found the following:
ArrayExpected: #/sessionRequest.organisation.identifier, but found {ArrayExpected: #/sessionRequest.organisation.identifier}.
请让我知道我正在创建的json文件是否与json模式兼容。我认为这就是问题所在