2015-02-17 56 views
1

我们与格式属性JSON模式,下面的代码片段:JSON模式 - 格式属性与JSON.Net

"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://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.23

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

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

+0

你有一个缺少的闭合大括号? – 2015-02-18 00:00:58

+0

@ nick-s是的,我喜欢。我已经纠正它,谢谢。 – Apeksha 2015-02-18 23:03:12

回答

1

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

+0

谢谢詹姆斯。所以我想这是Json.Net以前版本的一个疏漏。 – Apeksha 2015-02-19 21:20:40

+0

我不确定你指的是什么。 Json.NET一直只支持“格式”作为字符串。 – 2015-02-26 21:49:44

+0

我提供的JSON片段用于工作。我不知道为什么或如何。 – Apeksha 2015-02-27 22:33:20