【问题标题】:Is there an elif/elseif/switch statement in JSON-Schema?JSON-Schema 中是否有 elif/elseif/switch 语句?
【发布时间】:2019-09-18 15:50:53
【问题描述】:

JSON-Schema 中是否有 elif/elseif/switch 语句?我好像不在。

【问题讨论】:

    标签: if-statement switch-statement json-schema-validator


    【解决方案1】:

    您可以将“allOf”与 if 语句的对象列表一起使用

     "allOf": [
        {
          "if": {...},
          "else": {...}
        },
        {
          "if": {...},
          "else": {...}
        }
      ]
    

    请注意,此列表需要位于它所引用的项目的对象级别!

    来源:https://json-schema.org/understanding-json-schema/reference/conditionals.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-11-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多