-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Key gets modified if it contains "\" #395
Comments
Your code can't possibly compile cleanly in the form that you listed it here: \d and \g are undefined escape sequences. If you ignore the compiler warnings, and try to use it anyway, then the backslashes are just dropped, and you end up with a string that just contains "abcdefghi". On the other hand, if you have forward slashes in the string, then the inclusion of the backslashes in the result from json_object_to_json_string() is the intended output. |
Hello, Is there any workaround in the version I am using. |
That flag was added in commit 316da85, back at the end of 2015. It sounds like you're working off of a very old development version of json-c (somewhere between 2014/04/10 and 2015/11/28) and you should upgrade. |
json_object_object_add(object, "abc\def\ghi", value);
::std::string data(json_object_to_json_string(object));
cout << data << endl;
if the key contains "\", the content of key is getting changed to "abc\/def\/ghi" which is not intended.
The text was updated successfully, but these errors were encountered: