-
-
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
Value with spaces cannot be parsed #2781
Comments
The file |
Also I can create this json using this library but cannot read it. My system is: Linux o3 5.8.0-53-generic #60~20.04.1-Ubuntu SMP x86_64 x86_64 x86_64 GNU/Linux |
Data is parsed like that:
|
Your code does not read the complete file into the string, but only until the first space is read. This is not related to this library. If I output
Then, the error message makes sense, because indeed a closing quote is missing. The following works: #include <fstream>
#include <iostream>
#include "json.hpp"
int main()
{
std::string path = "/Users/niels/Downloads/prov.txt";
std::ifstream i(path);
nlohmann::json rootJson = nlohmann::json::parse(i);
std::cout << rootJson << std::endl;
} Output: {"testKey":"Value with spaces"} |
Great, thanks for the help. |
I cannot parse simple JSON if it has spaces in the value:
{"testKey":"Value with spaces"}
I have exception:
terminate called after throwing an instance of 'nlohmann::detail::parse_error'
what(): [json.exception.parse_error.101] parse error at line 1, column 18: syntax error while parsing value - invalid string: missing closing quote; last read: '"Value'
Version: 3.9.1
The text was updated successfully, but these errors were encountered: