2015-02-17 55 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