Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我直到现在才使用 json,所以我不熟悉编写 json 模式
请让我知道如何编写一个 json 模式来匹配单个字符作为键和数字作为值
例如:
{"M":1}
提前致谢
这是一个解决方案:
{ "type": "object", "patternProperties": { "^[a-zA-Z]$": { "type": "number" } } }
请注意,您没有指定这是否是您在实例中允许的唯一键;甚至它必须存在。在这种情况下查看minProperties和maxProperties模式关键字。
minProperties
maxProperties