我想知道是否有人可以给出一个对使用“anyOf”关键字的模式有效的 JSON 示例?我正在尝试编写一些将在 python 中输出有效 JSON 的代码。
例如,如果您有一个如下所示的架构:
"anyOf": {
"category_0": {
"main": { "enum": ["learning"]},
"sub": { "enum": ["ADD/ADHD", "dyslexia", "general learning disability", "language disorder", "intellectual giftedness", "other"]}
},
"category_1": {
"main": { "enum": ["mental"]},
"sub": { "enum": ["down's syndrome", "asperger's syndrome", "autism", "other"]}
},
"category_2": {
"main": { "enum": ["behavioral"]}
},
"category_3": {
"main": { "enum": ["medical"]},
"sub": { "enum": ["diabetes", "allergies", "eating disorders", "chronic illness", "other"]}
},
"category_4": {
"main": { "enum": ["physical"]},
"sub": { "enum": ["blind", "deaf", "cerebral palsy", "other"]}
}
}
什么 JSON 是有效的?
我用来在 python 中输出 JSON 的代码是这样的:
main = row.get('main', [])
sub = row.get('sub',[])
category = dict(main = main, sub=sub)
special_needs = category