我在设置JSON模式时遇到问题,该模式将验证JSON是否包含:
但是当它们的倍数存在时不匹配.
在我的具体情况下,我想要一个
copyAllfileNamesmatchesFiles 和/或 doesntMatchFiles验证,但我不想接受超过那个.
这是我到目前为止所得到的:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"required": [ "unrelatedA" ],
"properties": {
"unrelatedA": {
"type": "string"
},
"fileNames": {
"type": "array"
},
"copyAll": {
"type": "boolean"
},
"matchesFiles": {
"type": "array"
},
"doesntMatchFiles": {
"type": "array"
}
},
"oneOf": [
{"required": ["copyAll"], "not":{"required":["matchesFiles"]}, "not":{"required":["doesntMatchFiles"]}, "not":{"required":["fileNames"]}},
{"required": ["fileNames"], "not":{"required":["matchesFiles"]}, "not":{"required":["doesntMatchFiles"]}, "not":{"required":["copyAll"]}},
{"anyOf": [
{"required": ["matchesFiles"], "not":{"required":["copyAll"]}, "not":{"required":["fileNames"]}},
{"required": ["doesntMatchFiles"], "not":{"required":["copyAll"]}, "not":{"required":["fileNames"]}}]}
]
} ;
Run Code Online (Sandbox Code Playgroud)
这比我想要的更多.我希望这匹配以下所有内容:
{"copyAll": true, "unrelatedA":"xxx"}
{"fileNames": …Run Code Online (Sandbox Code Playgroud) FTDI 是否实现标准通信设备类 (CDC) USB 协议?
我需要在 STM32 上实现一个主机,以将设备连接到 FTDI 串行芯片。但谷歌搜索显示,使用 ST 的库时会出现问题。