-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
json::parse throws std::invalid_argument when processing string generated by json::dump() #863
Comments
|
Thanks for quick response.
exception string is: "parse error - unexpected '"'" unexpected token is: parse_error (14)
I have tried it and still see the exception. The information looks like below: "syntax error - invalid string: ill-formed UTF-8 byte; last read: '"正'" Please note that I use '\uXXXX' notation for Chinese characters in source code. |
The Chinese version of Visual Studio encodes the source files in gb2312 (like Excel and others), while the GCC default encoding is UTF-8. I think that is the cause of the exception. I tried "Save as..." to save source file as Unicode (Code Page 1200), Unicode (UTF-8 With Signature, Code Page 65001), the problem still exits. If so, it is really a sticky problem. >_< |
The library only supports UTF-8 encoded strings. If a string with a different encoding is stored, the resulting serialization may be incompliant JSON. We discuss in #838 whether we shall throw an exception in case non-UTF-8 encodings are detected during serialization. |
Merged #870: Trying to serialize a non-UTF-8 encoded string now throws an exception. |
Bug Report
I generate a JSON string with json::dump(), and pass to another thread. The thread calls json::parse() to get an object from the JSON string and it throws std::invalid_argument exception.
The following codes throws the exception:
The JSON string:
Try the following code and exception will show up:
Parse the JSON string and return an object.
Throwing an exception, the std::invalid_argument
VS 2017 Community
develop
branch?Release 2.1.1
No.
Feature Request
Above is enough maybe.
See above.
The text was updated successfully, but these errors were encountered: