how to deserialized the Messagepack data On REST server client

406 Views Asked by At

I am trying to use message pack library t serialize my data in REST server client environment

I and serialize the data using the code below :

 std::vector<std::string> target;
    target.push_back("Hello,");
    target.push_back("World!");

    // Serialize it.
    msgpack::sbuffer sbuf;  // simple buffer
    msgpack::pack(&sbuf, target);

and sending the data using fastcgipp library and send the Output to client using the line :

 out << sbuf.data();

and the client gets the message but when I try to deresialize it using the code :

     msgpack::sbuffer lineStream(stBinary.length());
                lineStream.write(stBinary.c_str(), stBinary.length());
               msgpack::unpacked msg;    // includes memory pool and deserialized object
                msgpack::unpack(&msg, lineStream.data(), lineStream.size());
               msgpack::object obj = msg.get();

 std::cout <<"OBJECT__" <<obj << std::endl;  //=> ["Hello", "MessagePack"]

I get the OUTPUT OBJECT__72 and not the expected output which is :

["Hello", "MessagePack"]

What can be the reason?

0

There are 0 best solutions below