Update: The problem was I didn't close file after downloading JSON. You need to close file at first and only then parse with nlohmann.
I'm trying to parse JSON in C++ with nlohmann/json library. But this library can't parse not formatted JSON.
It gives error:
libc++abi.dylib: terminating with uncaught exception of type nlohmann::detail::parse_error: [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
This JSON gives error:
But nlohmann works fine with JSON like this:
Update: here was another json
Is there a way to format JSON from first format to the second one in C++ code? Without using websites. Maybe there's a library for this, or it's achievable with just C++ or STL.
Update: The problem was I didn't close file after downloading JSON. You need to close file at first and only then parse with nlohmann. The same what I wrote in the beginning of this comment. Just in case somebody misses it.
Update: The problem was I didn't close file after downloading JSON. You need to close file at first and only then parse with nlohmann.
I'm trying to parse JSON in C++ with nlohmann/json library. But this library can't parse not formatted JSON.
It gives error:
libc++abi.dylib: terminating with uncaught exception of type nlohmann::detail::parse_error: [json.exception.parse_error.101] parse error at line 1, column 1: syntax error while parsing value - unexpected end of input; expected '[', '{', or a literalThis JSON gives error:
But nlohmann works fine with JSON like this:
Is there a way to format JSON from first format to the second one in C++ code? Without using websites. Maybe there's a library for this, or it's achievable with just C++ or STL.
Update: The problem was I didn't close file after downloading JSON. You need to close file at first and only then parse with nlohmann. The same what I wrote in the beginning of this comment. Just in case somebody misses it.