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

Non-verifying dump() alternative for debugging/logging needed #1335

Closed
ghost opened this issue Nov 5, 2018 · 2 comments
Closed

Non-verifying dump() alternative for debugging/logging needed #1335

ghost opened this issue Nov 5, 2018 · 2 comments
Labels
kind: question solution: proposed fix a fix for the issue has been proposed and waits for confirmation

Comments

@ghost
Copy link

ghost commented Nov 5, 2018

I have an embedded application using json.hpp v3.2.0 that mysteriously fails when stresstesting on a foreign lab-setup outside my PC. From the log I can see the reported error "Invalid UTF-8" error at index 1 : 0xF5" but nothing more.

I can not debug the software directly, so I would like to log the illegal json as a string or hex dump, so I can better diagnose the problem.

Would it be possible to provide a non-verifying dump() method, that could make a best effort to print out as much as possible of the json - even in the presence of such errors? With such a method I could inspect the output and use a process of elimination to better locate the part of the json that has a problem.

@nlohmann
Copy link
Owner

nlohmann commented Nov 5, 2018

That means that the first or second byte is 0xF5 which is not valid in UTF-8.

With the latest release 3.4.0, it is possible to tell the dump function how to react on invalid Unicode, see the documentation, in particular the error handlers. There is also an example.

@nlohmann nlohmann added kind: question solution: proposed fix a fix for the issue has been proposed and waits for confirmation labels Nov 5, 2018
@ghost
Copy link
Author

ghost commented Nov 5, 2018

Great - that should work - thanks a lot !!

@ghost ghost closed this as completed Nov 5, 2018
This issue was closed.
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

1 participant