Skip to content

stream error  #815

Description

I've been trying to implement this solution and I have been consistently getting the same stream error, regardless of the json file or example I use/follow. I know I'm probably doing something silly but I'm a lowly junior in my CS degree. Here is my code:

#include "json.hpp"

#include <fstream>

using json = nlohmann::json;

int main() {
    std::ifstream ifs{"file.json"};
    json parsed_json = json::parse(ifs);
    return 0;
}

and here is the json I've been using:

[
  {
    "stringKey": "Nathen",
    "intKey": 236
  },
  {
    "stringKey": "Emerald",
    "intKey": 739
  },
  {
    "stringKey": "Franco",
    "intKey": 544
  }
]

and here is the error:
/home/bry/CLionProjects/jsonexample/cmake-build-debug/jsonexample terminate called after throwing an instance of 'std::invalid_argument' what(): stream error Process finished with exit code 134 (interrupted by signal 6: SIGABRT)

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions