Skip to content
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

Closed
1Hyena opened this issue Aug 15, 2018 · 5 comments
Closed

json.exception.type_error.316 #1195

1Hyena opened this issue Aug 15, 2018 · 5 comments
Labels
kind: question solution: proposed fix a fix for the issue has been proposed and waits for confirmation

Comments

@1Hyena
Copy link

1Hyena commented Aug 15, 2018

  • 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?

@nlohmann
Copy link
Owner

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.

@1Hyena
Copy link
Author

1Hyena commented Aug 15, 2018

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?

@nlohmann
Copy link
Owner

Exactly. The reason for this was that we kept running into issues when the library failed to parse JSON it produced itself.

@1Hyena
Copy link
Author

1Hyena commented Aug 15, 2018

Ok thanks again, probably something fishy happening in my code then. Will need to investigate. Closing this for now.

@1Hyena 1Hyena closed this as completed Aug 15, 2018
@1Hyena
Copy link
Author

1Hyena commented Aug 15, 2018

If dump can throw though, then perhaps adding the necessary try catch blocks to the example code in README.md might be a good idea. Give it a thought ;)

@nlohmann nlohmann added kind: question solution: proposed fix a fix for the issue has been proposed and waits for confirmation labels Aug 15, 2018
@1Hyena 1Hyena reopened this Aug 15, 2018
@1Hyena 1Hyena closed this as completed Aug 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: question solution: proposed fix a fix for the issue has been proposed and waits for confirmation
Projects
None yet
Development

No branches or pull requests

2 participants