JSON Schema with unknown property names

后端 未结 3 1849
太阳男子
太阳男子 2021-02-06 21:41

I want to have a JSON Schema with unknown property names in an array of objects. A good example is the meta-data of a web page:

      \"meta\": {
        \"typ         


        
3条回答
  •  别那么骄傲
    2021-02-06 22:04

    The Solution of @jruizaranguren works for me. Though I am the same who defines the schema, i choosed another solution

    "meta": {
            "type": "array",
            "items": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "value": {
                    "type": "string"
                  }
                }
              }
            }
          }
    

    I converted the object to an array of name-value objects An example of a valid JSON:

    "meta": [
        [
          {
            "name": "http-equiv",
            "value": "Content-Type"
          },
          {
            "name": "content",
            "value": "text/html; charset=UTF-8"
          }
        ],
        [
          {
            "name": "name",
            "value": "author"
          },
          {
            "name": "content",
            "value": "Astrid Florence Cassing"
          }
        ]
      ]
    

提交回复
热议问题