-
-
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.exception.type_error.316 #1195
Comments
The exception should contain the description that you try to dump a non-UTF-8 encoded string. The library only supports UTF-8. See the documentation for more information. |
Whoa, what a quick reply, thanks! I would have thought that when assigning a string value to the json object it would later be able to do the encoding itself, but as I can see now it is not always the case? For example, if I assign an std::string that contains invalid utf8 bytes then later dumping it would produce this exception? |
Exactly. The reason for this was that we kept running into issues when the library failed to parse JSON it produced itself. |
Ok thanks again, probably something fishy happening in my code then. Will need to investigate. Closing this for now. |
If dump can throw though, then perhaps adding the necessary try catch blocks to the example code in |
What is the issue you have?
After getting the latest version of this json library from its github repository my program started to crash randomly. It did not crash with the previous version. The reason of the crash seems to be an exception that was not thrown before. From the source code it seems that 316 is thrown during dumping the json object which I wouldn't ever anticipate. Why would dumping fail? The description of the said exception does not help me to understand its real cause.
Please describe the steps to reproduce the issue. Can you provide a small but working code example?
My program has to sometimes run for more than 12h to get this exception. I have no idea how to reproduce it.
What is the expected behavior?
Well if this is a valid exception that users must 100% be prepared for then I'd have expected some documentation about it. Although I must admit getting an exception from the dump call feels unnatural.
And what is the actual behavior instead?
Seems that calls to the dump function can throw an exception that wasn't thrown before with the old version of the lib that I had.
Which compiler and operating system are you using? Is it a supported compiler?
g++ (Ubuntu 5.4.0-6ubuntu1~16.04.10) 5.4.0 20160609
Ubuntu server
Did you use a released version of the library or the version from the
develop
branch?Used this one from yesterday:
https://github.com/nlohmann/json/tree/develop/single_include/nlohmann
If you experience a compilation error: can you compile and run the unit tests?
The text was updated successfully, but these errors were encountered: