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

conversion to std::string failed #1571

Closed
somequery opened this issue Apr 17, 2019 · 1 comment
Closed

conversion to std::string failed #1571

somequery opened this issue Apr 17, 2019 · 1 comment

Comments

@somequery
Copy link

I have difficulties with dumping all data from a json object into a string.

I created a json object with multyple fields and assigned values to them. The data types are std::string, unsigned int, ushort, and pid_t. I can successfully read the data back with a statement:
jsonMsg[item_name].get<item_type>();

However, when I want to return the created json object as a std::string object, this fails:
std::string strJson = jsonMsg.get<std::string>();
also this:
std::string strJson = jsonMsg.dump();

I want to represent the nlohmann::json as bunch of bytes stored in std::string so I could pass it across software modules and at the end just convert these bytes back to nlohmann json object.

I was doing this with the boost property tree. Can I do it with nlohmann json?

Thank you for help.

@somequery
Copy link
Author

I found extended ASCII characters in one field which causes the problem.

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

1 participant