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

Extra backslashes in nested json #2020

Closed
machadors opened this issue Mar 31, 2020 · 2 comments
Closed

Extra backslashes in nested json #2020

machadors opened this issue Mar 31, 2020 · 2 comments

Comments

@machadors
Copy link

There is an extra backslash when adding nested json.

This operations
json foo;
foo["key"] ="{\"hey\":\"hou\"}";
std::string result = foo.dump();

gives
result = "{\"key\":\"{\\\"hey\\\":\\\"hou\\\"}\"}"
with an extra backslashes in the nested json.

Is this a bug or there is another way to adding nested json ?

PD: This is my first ever github question, sorry in advance about format and so

@sanblch
Copy link

sanblch commented Apr 2, 2020

You need to explicitly show json type like
foo["key"] = json::parse("{\"key\":\"hou\"}");

@machadors
Copy link
Author

Yes, I have. Thanks for the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants