Skip to content

Parse error on valid json file #2029

Description

@nittdeniz

I validated my JSON file with various tools online and they confirm that my JSON file has valid syntax. Yet I get a parse error

[
  {
    "particles": [
      ["antilepton", "lepton"],
      ["antilepton", "lepton"],
      ["photon"]
    ],
    "indices": [
      [],
      [],
      ["mu"]
    ],
    "rule": "-i*e*GA[mu]"
  }
]

what(): [json.exception.parse_error.101] parse error at line 1, column 1: syntax error while parsing value - unexpected end of input; expected '[', '{', or a literal

To read the file I copied the example code from the README

std::ifstream ifs("my_file.json");
/*
std::stringstream ss;
ss << ifs.rdbuf();
std::cout << ss.str() << "\n";
// prints the file, so path is correct
*/

JSON json;
ifs >> json;
std::cout << json << "\n";

I also tried adding zeros in the empty arrays, but that didn't help either.

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