Feature Request
It would be nice to get the path of the json file when an error occurs. Currently, only the type of the error is printed, with no way to know where in the json tree it happend, so it is very difficult to find the error.
For parse errors, I have implemented a way to show the place of the error:
try {
return json::parse(f);
} catch( nlohmann::detail::parse_error &e ) {
Xtring err = e.what();
std::cout << err << std::endl;
if (e.byte > 1 )
f.seekg(e.byte - 2);
else
f.seekg(0);
char text[121];
f.read(text, 120);
std::cout << text << std::endl;
exit(1);
}
}
And for type errors, I have tweaked the code for every JSON_THROW so that I get a dump of the value being parsed. But as I can not get the parent nor the name, only the value, I don't know where the error in the parse tree es:
JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()) + j.dump() ));
Feature Request
It would be nice to get the path of the json file when an error occurs. Currently, only the type of the error is printed, with no way to know where in the json tree it happend, so it is very difficult to find the error.
For parse errors, I have implemented a way to show the place of the error:
And for type errors, I have tweaked the code for every JSON_THROW so that I get a dump of the value being parsed. But as I can not get the parent nor the name, only the value, I don't know where the error in the parse tree es: