Skip to content

Parse a 2019 schema with relative refs #627

Answered by danielaparker
Kristallfee asked this question in Q&A
Discussion options

You must be logged in to vote

I think the issue is that you're using the keyword definitions rather than $defs with a 2019 JSON Schema. jsoncons can recognize definitions, but only if you specify "compatibility mode", i.e.,

try
{
    auto sch = jsoncons::json::parse(schema_str);

    auto options = jsoncons::jsonschema::evaluation_options{}
        .compatibility_mode(true);
    auto schema = jsoncons::jsonschema::make_json_schema(sch, options);
}
catch (const std::exception& e)
{
    std::cout << e.what() << "\n";
}

Admittedly the diagnostic message could be better.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Kristallfee
Comment options

Answer selected by Kristallfee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants