Skip to content

Enable forward declaration of json by making json a class instead of a using declaration #997

Closed
@pgoodman

Description

I would like to be able to be able to declare the conversion operators in a header without having to #include the json.h file. I would then define the conversion operators in a source file, which actually includes json.h.

Here is an example of what I want do do, but can't:

namespace nlohmann {
class json;
void to_json(json &j, const MyType &blah);
void from_json(const json &j, MyType &blah);
}  // namespace nlohmann

What is stopping me is using json = basic_json<>;. A simple fix should be class json : public basic_json<> {};.

Metadata

Assignees

No one assigned

    Labels

    state: needs more infothe author of the issue needs to provide more details

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions