Skip to content

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

Description

@pgoodman

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<> {};.

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

    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