JSON 用于验证不带时区的日期时间的架构
JSON Schema to validate DateTime without timezone
JSON 架构日期时间格式检查具有 2018-11-13T20:20:39+00:00
.
等时区的日期时间
但是我的日期时间没有时区部分。
只有日期和时间,例如 2018-11-13T20:20:39
。
有什么方法可以验证没有时区的日期时间吗?
是的。此架构:
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"thedate":{
"type":"string",
"format":"date-time"
}
}
}
将验证此实例:
{
"thedate":"2018-11-13T20:20:39"
}
正如@gregsdennis 在他的评论中指出的那样,根据您使用的解析器,“格式”关键字的支持或实现可能会有所不同。
JSON 架构日期时间格式检查具有 2018-11-13T20:20:39+00:00
.
但是我的日期时间没有时区部分。
只有日期和时间,例如 2018-11-13T20:20:39
。
有什么方法可以验证没有时区的日期时间吗?
是的。此架构:
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"thedate":{
"type":"string",
"format":"date-time"
}
}
}
将验证此实例:
{
"thedate":"2018-11-13T20:20:39"
}
正如@gregsdennis 在他的评论中指出的那样,根据您使用的解析器,“格式”关键字的支持或实现可能会有所不同。