patternProperties 的 Json 模式示例

标签 json json.net jsonschema

谁能给我一个如何使用 json 模式的 patternProperties 项目的例子?

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

我想在 json 文件中做的是允许以 A 开头的“示例”的任何子项
例如。:
{
  "Example" : 
  {
    "Aaa" : { ...}
  }
}

patternProperties 是正确的选择吗?

最佳答案

{
  type: 'object',
  patternProperties: {
    '^A': {
      type: 'string',
      ...
    }
  }
}

关于patternProperties 的 Json 模式示例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9702843/

相关文章:

java - 无法在 scala 中使用 jackson fastxml 将 json 数组反序列化为类对象

json.net - 在 ASP.NET Core 中检测到自引用循环

c# - 具有多态子对象的类型的 Json.Net 序列化

arrays - 对象数组的 Json 架构未验证

json - 使用 log4j2 编写自定义 json 消息的最佳方法

c# - 将日期时间转换为 JSON 数据有困难

javascript - 如何选择和比较 JSON 数据的值(value)?

c# - 将 JSON 对象属性反序列化为字符串

JSON Schema : Using anyOf, oneOf, allOf 在 additionalProperties 中

ruby - 如何为对象数组编写 JSON 模式?