diff --git a/src/json-validator.cpp b/src/json-validator.cpp index 75f5bd8..8b637a8 100644 --- a/src/json-validator.cpp +++ b/src/json-validator.cpp @@ -226,6 +226,7 @@ class root_schema // for each token create an object, if not already existing auto unk_kw = &file.unknown_keywords; for (auto &rt : ref_tokens) { + // create a json_pointer from rt as rt can be an stringified integer doing find on an array won't work json::json_pointer rt_ptr{"/" + rt}; if (unk_kw->contains(rt_ptr) == false) (*unk_kw)[rt] = json::object(); diff --git a/test/issue-311/instance.json b/test/issue-311/instance.json index e571d98..508124e 100644 --- a/test/issue-311/instance.json +++ b/test/issue-311/instance.json @@ -1,3 +1,4 @@ { - "element": [1] + "element": [1], + "element2": "test" } diff --git a/test/issue-311/schema.json b/test/issue-311/schema.json index 3be1b40..9bb41a4 100644 --- a/test/issue-311/schema.json +++ b/test/issue-311/schema.json @@ -3,6 +3,9 @@ "properties": { "element": { "$ref": "#/$defs/element" + }, + "element2": { + "$ref": "#/$defs/element/items/0/$defs/element2" } }, "$defs": { @@ -10,7 +13,11 @@ "type": "array", "items": [ { - "$comment": "the comment should not lead to fail of loading schema", + "$defs": { + "element2": { + "type": "string" + } + }, "type": "number" } ]