[英]How to define property of type percentage in Json Schema 4
I am designing a Json schema and I want to show percentage. 我正在设计一个Json架构,我想显示百分比。 I am not sure which type i should select to define percentage in Json schema.
我不确定应该选择哪种类型来定义Json模式中的百分比。 any help would be appreciated.
任何帮助,将不胜感激。
"rate": { "type": "percentage" }
There is no percentage type in json schema. json架构中没有百分比类型。
You could do this: 你可以这样做:
{
"type": "number",
"minimum": 0,
"maximum": 1,
}
and use the fraction. 并使用分数。
Or if you want to use numbers between 0 and 100: 或者,如果要使用0到100之间的数字:
{
"type": "number",
"minimum": 0,
"maximum": 100,
}
Also, you could add the "multipleOf" keyword to specify how much decimals you want. 此外,您可以添加“multipleOf”关键字来指定您想要多少小数。 For example "multipleOf: 0.1" (for 1 decimal) or "multiplpeOf: 0.01" (for 2 decimals)
例如“multipleOf:0.1”(1个十进制)或“multiplpeOf:0.01”(2个小数)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.