Skip to content

example code for ifstream reading a json file results in no operator error #1766

Description

@desluOs
#include <nlohmann/json.hpp>
#include <iostream>
#include <fstream>
using namespace std;
using json = nlohmann::json;
void run() {
		ifstream in("test.json");
		json j;

		in >> j;

is where the problem occurs, with the >> the only thing resulting in an error. I got the setup from the example code for reading json files. This is happening in a header file. Everything compiles with warnings and will run, but errors out when it gets to this point.

C++ no operator matches these operands operand types are: std::ifstream >> json

is the exact text given when hovering over the red underlined >>;

Not sure what I'm missing, sorry if it's obvious but I tried to find a solution elsewhere first.

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