Skip to content

Remove deprecated constructor basic_json(std::istream&) #480

Description

@nlohmann

Function

explicit basic_json(std::istream& i, const parser_callback_t cb = nullptr)

has been deprecated since version 2.0.0 (June 24, 2016) to unify the interface of the library. Deprecation warnings were produced with GCC, Clang, and MSVC.

To create objects from an input stream, there remain the following possibilities:

  • with callback:
    • parse(std::istream& i, const parser_callback_t cb = nullptr)
  • without callback
    • std::istream& operator<<(basic_json& j, std::istream& i)
    • std::istream& operator>>(std::istream& i, basic_json& j)

That is, code without callback cb

json j(i);

must be replaced by either

// alternative 1
json j = json::parse(i);

// alternative 2
json j;
j << i;

// alternative 3
json j;
i >> j;

Code with a callback function cb

json j(i, cb);

must be replaced by

json j = json::parse(i, cb);

Activity

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions