JSON schema学习

遇到json中有数组结构JSON schema格式处理:

json数据:

{
  "name": "test",
  "userList": [
    {
      "age": "12",
      "name": "hello"
    },
    {
      "age": "12",
      "name": "hello"
    }
  ]
}

JSON schema:

{

  "type": "object",
  "properties": {
    "name": {
      "type": "string"
    },
    "userList": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "age": {
            "type": "string"
          },
          "name": {
            "type": "string"
          }
        },
        "required": [
          "age",
          "name"
        ]
      }
    }
  },
  "required": [
    "name",
    "userList"
  ]
}

猜你喜欢

转载自www.cnblogs.com/me168/p/11005408.html