gpt4 book ai didi

jsonschema - 如何限制 JSON 模式中对象键的最大长度

转载 作者:行者123 更新时间:2023-12-05 02:21:05 25 4
gpt4 key购买 nike

我想限制类型为object 的属性键的最大长度。它的所有值都是在运行时生成的,我想通过在进一步处理之前验证文档来尽快发现不当行为。

最佳答案

你可以这样写:

{
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "Object with 10 char max properties",
"type": "object",
"additionalProperties": false,
"minProperties": 1,
"patternProperties":
{
"^[a-z]{0,10}$":
{
"description": "Some description",
"type": "string"
}
}
}

关于jsonschema - 如何限制 JSON 模式中对象键的最大长度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36226710/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com