Skip to content

Commit ed46fde

Browse files
fix issue-311
1 parent c6cb3d4 commit ed46fde

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed

src/json-validator.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,10 @@ class root_schema
192192
// for each token create an object, if not already existing
193193
auto unk_kw = &file.unknown_keywords;
194194
for (auto &rt : ref_tokens) {
195-
auto existing_object = unk_kw->find(rt);
196-
if (existing_object == unk_kw->end())
195+
json::json_pointer rt_ptr{"/" + rt};
196+
if (unk_kw->contains(rt_ptr) == false)
197197
(*unk_kw)[rt] = json::object();
198-
unk_kw = &(*unk_kw)[rt];
198+
unk_kw = &(*unk_kw)[rt_ptr];
199199
}
200200
(*unk_kw)[key] = value;
201201
}

test/issue-311/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
add_test_simple_schema(Issue::311
2+
${CMAKE_CURRENT_SOURCE_DIR}/schema.json
3+
${CMAKE_CURRENT_SOURCE_DIR}/instance.json)

test/issue-311/instance.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"element": [1]
3+
}

test/issue-311/schema.json

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"type": "object",
3+
"properties": {
4+
"element": {
5+
"$ref": "#/$defs/element"
6+
}
7+
},
8+
"$defs": {
9+
"element": {
10+
"type": "array",
11+
"items": [
12+
{
13+
"$comment": "the comment should not lead to fail of loading schema",
14+
"type": "number"
15+
}
16+
]
17+
}
18+
}
19+
}

0 commit comments

Comments
 (0)