![](/img/trans.png)
[英]transform file/directory structure into 'tree' in vue json, how can add new field to new json type?
[英]How can i add a new type or data type in json schema or adding conditional statements in JSON
您好,我正在处理我需要开发基于 json 的 ui 的应用程序,这里我的要求是有某些属性,我可以使用这些属性添加到 json 中,我需要从中开发一个表、下拉列表等。我可以直接添加这些吗?
对于前
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://example.com/product.schema.json",
"title": "Dynamic",
"description": "ui from json",
"type": "object",
"properties": {
"population": {
"description": "The unique identifier for a product table",
"type": "table"
},
"countries": {
"description": "The unique identifier for a product table",
"type": "dropdown"
}
}
}
或者如果我们提到type:string那么我们如何在 json 中清楚地提到什么是表以及什么是下拉列表或“我如何在 json 结构中添加 if 条件语句
你想要的是一个enum
。 此关键字将允许您指定任意数量的有效离散值(字符串或其他)。
{ "enum": [ "red", "orange", ... ] }
或者,如果要支持十六进制代码,可以使用pattern
指定字符串必须满足的正则表达式。
{
"type": "string",
"pattern": "..."
}
您仍然需要在此处将类型指定为字符串,因为pattern
仅适用于数据为字符串的情况; 如果数据不是字符串,它什么也不做。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.