Custom server message

Hello, I have to create a custom server message with the following structure

empty


response

in which the response is a dictionary
how do you suggest to do it?
thanks
Salvatore

p.s. at moment I am using the following trick


string key
string value

so i deconstruct the dict - transport and after contruct it again

Hi @saxosun ,

Since you want to provide a dictionary as response, I suggest that you use this structure:

# request

---
# response
string dict

Since you’re using dictionary, I’m assuming that you are going to use a python program to format string back to a dictionary.
Instead of using two strings as response, one for keys and another for values, just use one string and convert the dictionary to string and send it as response. This is easier.
You can later use ast.literal_eval() function in python to change the string back to dictionary in the response.

I hope this suggestion helps you.

Regards,
Girish

Hi Girish
thanks for your reply. The problem is a little more complicated, sorry if I do not explained it before.
The server that creates the nested dictionary is written in python, instead the client in c++. So the client, as you suggest, will receive a converted (string) dictionary that has to be converted in an unordered-map. What do you could me suggest with these details more?
I will try to solve using this post:

Thanks and Regards
Salvatore

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.