Correct JSON Schema for an array of items of different type

后端 未结 5 1315
渐次进展
渐次进展 2020-12-16 10:56

I have an unordered array of JSON items. According to the specification http://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.5 the json schema below will only vali

5条回答
  •  一向
    一向 (楼主)
    2020-12-16 11:17

    I've been looking into this for quite a while too. But haven't been able to find a working solution. It works fine if you have only one schema eg.

    "transactions" : {
              "type" : "array",
              "items" : 
              {
                "type" : "object",
                "properties" : {
                  "type" : {
                    "type" : "string",
                    "enum" : ["BREAK"]
                  },
              }
    }
    

    Then you just skip the array brackets, and use an object. However if you want to do what you are doing, there seems to be no solid answer. This is the only thing that I've found so far: http://the-long-dark-tech-time.blogspot.se/2012/12/using-json-schema-with-array-of-mixed.html

提交回复
热议问题