-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't throw exception when starting file is a number #1649
Comments
The issue is that parsing via For your case, try using the static function Here is an example: #include "json.hpp"
#include <iostream>
#include <sstream>
using json = nlohmann::json;
int main()
{
// works and prints "123"
{
std::stringstream ss;
ss << "123ab" << std::endl;
json j;
ss >> j;
std::cout << j << std::endl;
}
// throws [json.exception.parse_error.101] parse error at line 1, column 4: syntax error while parsing value - invalid literal; last read: '123a'; expected end of input
{
std::stringstream ss;
ss << "123ab" << std::endl;
json j = json::parse(ss);
}
} |
@h3x4n1um Do you need further assistance? |
Thankyou, that's very kind of you but I think using |
For |
When parsing binary file, if several first bytes of file is number, the json parser not throw an exception
The below example show that it recognize
fake_undetected.json
file is a json fileIt should throw
nlohmann::json::exception
when parsefake_undetected.json
Opposite above
I use GCC 9.0 (MSYS2 with MinGW-w64 package) and compile using
develop
branch?I use released version 3.6.1 of the library
Hello, world!
The text was updated successfully, but these errors were encountered: