我有一个 MVC 应用程序,它将我的模型序列化为 json 模式(使用 Newtonsoft json.net 模式)。问题是我的数组中的项目有 type ["string", "null"],但我需要的只是"string". 这是我班级的代码:
public class Form
{
[Required()]
public string[] someStrings { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
这是由 Json.net 架构制作的架构:
"someStrings": {
"type": "array",
"items": {
"type": [
"string",
"null"
]
}
}
Run Code Online (Sandbox Code Playgroud)
虽然我期待这个:
"someStrings": {
"type": "array",
"items": {
"type": "string"
}
}
Run Code Online (Sandbox Code Playgroud)
请帮我摆脱那个“空”。