我有一个有效的 json 模式,如下所示
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "abcd",
"title": "test schema",
"description": "............",
"type": "object",
"properties": {
"a": {
...........
...........
},
"b": {
.........
........
.........
},
"c": {
...........
..........
},
"d": {
...........
..........
}
},
"anyOf": [
{
"type": "object",
"$ref": "#/properties/a",
"$ref": "#/properties/b"
},
{
"type": "object",
"$ref": "#/properties/c",
"$ref": "#/properties/d"
}
]
}
上面的模式存储在一个文件中,我正在加载它进行解析,如下所示
JSchema schema =
JSchema.Parse(File.ReadAllText(@"D:\Backups\testschema.json"));
所以当我查看模式的输出时,它如下所示
My Json Schema
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "abcd",
"title": "test schema",
"description": "............",
"type": "object",
"properties": {
"a": {
...........
...........
},
"b": {
.........
........
.........
},
"c": {
...........
..........
},
"d": {
...........
..........
}
},
"anyOf": [
{
"$ref": "#/properties/b"
},
{
"$ref": "#/properties/d"
}
]
}
I'm wondering why I'm getting only the last reference under the anyOf property
On parsing shouldn't the output be the same as that in the file?
Am I missing something?
My desired output under anyOf is
"anyOf": [
{
"type": "object",
"$ref": "#/properties/a",
"$ref": "#/properties/b"
},
{
"type": "object",
"$ref": "#/properties/c",
"$ref": "#/properties/d"
}
]
关于如何实现我想要的输出有什么想法吗?
手掌心
相关分类