JSON Schema-具有JSON.Net的格式属性



我们有一个具有format属性的JSON模式,代码段如下:

"properties": {
        "expireDateTime": {
        "description": "Date when the time will expire.  If granularity is at the date level then YYYY-MM-DD is passed.  If the granularity is at the hour/minute level then the date time format is YYYY-MM-DDThh:mm:ss+-hh:mm",
        "type": "string",
        "format": [ "date-time", "date" ]
        } }

我们正在使用NewtonSoft的Json.Net解析器来处理它。这在以前版本的框架(v6.x)中用于正确解析,该版本仅支持草案3。对于支持草案4的框架的最新版本,我得到了一个错误,即格式不能是数组。

我环顾四周,在草案3规范中没有看到任何内容表明格式可以是数组,也不能是数组。https://datatracker.ietf.org/doc/html/draft-zyp-json-schema-03#section-5.23

然而,草案4明确规定格式必须是字符串。http://json-schema.org/latest/json-schema-validation.html#anchor79

我认为Json.Net框架在这方面不向后兼容,这是正确的吗?或者它在以前版本中的工作方式是错误的?它将帮助我们相应地处理这个问题。谢谢

在草案3中,format属性旨在作为字符串,而不是字符串数组。

最新更新