socket.io-client-cpp icon indicating copy to clipboard operation
socket.io-client-cpp copied to clipboard

how can i make a map have 2 keys ?

Open volzb opened this issue 6 years ago • 0 comments

just after a bit of help, I am not having much luck on stack overflow. below is a copy of my question if anyone knows how I can do this it much appreciated

I don't understand the correct syntax to create a deeper level to my map with socket io c++. I would like to create a map that matches the js object that I am receiving like below

var name = { key1: { Key1.1: 0, key1.2: 0 } } I can make the first level and send it using:

sio::message::ptr nameOfObj(sio::object_message::create()); std::map<std::string, sio::message::ptr> &map = nameOfObj->get_map();

map.insert(std::make_pair("v1",sio::string_message::create("mes1"))); map.insert(std::make_pair("v2",sio::string_message::create("mes2")));

current_socket->emit("ID", nameOfObj); I have tried to use the following code and links to help me.

nameOfObj["v1"].insert(std::make_pair("key2", "value2"))); I found this code from Storing std map in map but I do not have an insert function to allow me to create the next level

volzb avatar Dec 30 '18 11:12 volzb