【问题标题】:Json Schema Example for patternPropertiespatternProperties 的 Json 模式示例
【发布时间】:2012-03-30 23:08:27
【问题描述】:

谁能给我一个示例,说明如何将 patternProperties 项用于 json 架构?

"Example" :
  "type" : "object",
  "patternProperties" :
  {
     <how do I use this>
  }

我想要在 json 文件中做的是允许任何以 A 开头的“示例”子项 例如:

{
  "Example" : 
  {
    "Aaa" : { ...}
  }
}

patternProperties 是正确的选择吗?

【问题讨论】:

    标签: json json.net jsonschema


    【解决方案1】:
    {
      type: 'object',
      patternProperties: {
        '^A': {
          type: 'string',
          ...
        }
      }
    }
    

    【讨论】:

    • 所以 '^A' 必须只是一个正则表达式?如果字符串匹配验证通过?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-27
    • 1970-01-01
    • 1970-01-01
    • 2014-12-26
    相关资源
    最近更新 更多