小编Rya*_*yan的帖子

JSON Schema 比较两个属性为等长数组

我在架构中有两个属性,它们都是数组。我想比较它们的长度相等。

例如:

架构.json

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "thing": {
      "type": "object",
      "properties": {
        "fields": {
          "type": "array",
          "items": {}
        },
        "values": {
          "type": "array",
          "items": {}
        }
      },
      "required": ["fields", "values"]
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

数据.json

{
  "thing": {
    "fields:": ["age", "sex", "location"],
    "values:": [25, "Male", "Cape Town"]
  }
}
Run Code Online (Sandbox Code Playgroud)

我想要比较模式中字段和值的长度相同。我该怎么做?

json jsonschema

5
推荐指数
1
解决办法
2079
查看次数

标签 统计

json ×1

jsonschema ×1