Skip to content

Commit 396ffbb

Browse files
andrejlevkovitchpboettch
authored andcommitted
fix: issue-311
Fixes #311
1 parent 0034c11 commit 396ffbb

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
@@ -226,10 +226,10 @@ class root_schema
226226
// for each token create an object, if not already existing
227227
auto unk_kw = &file.unknown_keywords;
228228
for (auto &rt : ref_tokens) {
229-
auto existing_object = unk_kw->find(rt);
230-
if (existing_object == unk_kw->end())
229+
json::json_pointer rt_ptr{"/" + rt};
230+
if (unk_kw->contains(rt_ptr) == false)
231231
(*unk_kw)[rt] = json::object();
232-
unk_kw = &(*unk_kw)[rt];
232+
unk_kw = &(*unk_kw)[rt_ptr];
233233
}
234234
(*unk_kw)[key] = value;
235235
}

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)