Skip to content

json_schema fails to compile with wjson #734

Description

@rmadlal

Describe the bug

jsonschema::make_json_schema seemingly accepts any Json type, but fails to compile with a wjson at a random location in the code:

C:\Users\Ron\Code\jsoncons\include\jsoncons_ext\jsonschema\json_schema_factory.hpp(43): error C2665: 'jsoncons::basic_json<wchar_t,jsoncons::sorted_policy,std::allocator<char>>::find': no overloaded function could convert all the argument types

The error is at this line:

auto it = root_schema->find("$schema");

Replacing "$schema" with JSONCONS_CSTRING_CONSTANT(Json::char_type, "$schema") works, but there are many other places where adjustments need to be made in order for the code to be CharT-agnostic. Fixing that line makes compilation fail elsewhere.

I would expect either full support for all Json types, or an explicit enable_if for json/ojson only.

Enumerate the steps to reproduce the bug

Try to create a json_schema<wjson> object.

Include a small, self-contained example if possible

using jsoncons::wjson;
namespace jsonschema = jsoncons::jsonschema;

wjson schema = wjson::parse(LR"(
{
    "properties": {
        "foo": {
            "type": "string"
        }
    }
}
)");

jsonschema::json_schema<wjson> compiled = jsonschema::make_json_schema(schema);

What compiler, architecture, and operating system?

  • Compiler: MSVC
  • Architecture (e.g. x86, x64) x64
  • Operating system: Windows

What jsoncons library version?

  • Latest release 1.8.1
  • Other release ______
  • master

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions