ASP.NET 模型状态错误 $。在键值
ASP.NET ModelState Errors $. in KeyValue
我的模型有一个 属性 DateOfBirthUtc,它是 DateTime 类型并且有一个属性 [Required]。当我 post 这个模型对我的操作方法使用无效的 DateOfBirthUtc(空)时,我得到了预期的错误。
我不明白的是,为什么 ModelState 生成的 key/value 对中的错误称为“$.dateOfBirthUtc”,而“$”是什么意思。是什么意思,为什么要添加到密钥中?
{
"type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
"title": "One or more validation errors occurred.",
"status": 400,
"traceId": "00-6999b89fb406304fbc11a17676de581a-5b59646fda25f248-00",
"errors": {
"$.dateOfBirthUtc": [
"The JSON value could not be converted to System.DateTime. Path: $.dateOfBirthUtc | LineNumber: 4 | BytePositionInLine: 22."
]
}
}
这是您的 JSON 的根,它显示您的 属性 在根 JSON 对象中的位置
我的模型有一个 属性 DateOfBirthUtc,它是 DateTime 类型并且有一个属性 [Required]。当我 post 这个模型对我的操作方法使用无效的 DateOfBirthUtc(空)时,我得到了预期的错误。
我不明白的是,为什么 ModelState 生成的 key/value 对中的错误称为“$.dateOfBirthUtc”,而“$”是什么意思。是什么意思,为什么要添加到密钥中?
{
"type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
"title": "One or more validation errors occurred.",
"status": 400,
"traceId": "00-6999b89fb406304fbc11a17676de581a-5b59646fda25f248-00",
"errors": {
"$.dateOfBirthUtc": [
"The JSON value could not be converted to System.DateTime. Path: $.dateOfBirthUtc | LineNumber: 4 | BytePositionInLine: 22."
]
}
}
这是您的 JSON 的根,它显示您的 属性 在根 JSON 对象中的位置