Closed nobody93 closed 5 years ago
You can use std::stringstream
instead of std::cout
. And then, call std::stringstream::str()
member function. http://www.cplusplus.com/reference/sstream/stringstream/str/
Here is an example:
#include <msgpack.hpp>
#include <sstream>
#include <iostream>
int main() {
msgpack::zone z;
auto obj = msgpack::object(std::make_tuple(1, 23.4, false), z);
std::cout << obj << std::endl;
std::stringstream ss;
ss << obj;
std::string str = ss.str();
std::cout << str << std::endl;
}
Thank you so much redboltz for your prompt advice.
Hi,
I can unpack the message to msgpack::object and display the json format in std::cout << object, but I need to convert msgpack::object json format to either std::string or char , then insert a string json data to mysql json field, I failed both cast to char or std::string, please advise.
Thank you.