# Custom server message

**URL:** <https://get-help.theconstruct.ai/t/custom-server-message/24769>\
**Category:** ROSDS Support\
**Created:** [June 6, 2023, 3:46pm UTC](https://get-help.theconstruct.ai/t/custom-server-message/24769 "2023-06-06T15:46:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![saxosun](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/saxosun/32/9368_2.png) [@saxosun](https://get-help.theconstruct.ai/u/saxosun)\
**Post date:** [June 6, 2023, 3:46pm UTC](https://get-help.theconstruct.ai/t/custom-server-message/24769/1 "2023-06-06T15:46:28Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![girishkumar.kannan](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/girishkumar.kannan/32/6994_2.png) [@girishkumar.kannan](https://get-help.theconstruct.ai/u/girishkumar.kannan)\
**Post date:** [June 6, 2023, 5:00pm UTC](https://get-help.theconstruct.ai/t/custom-server-message/24769/2 "2023-06-06T17:00:19Z")

</div>

Hi @saxosun ,

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

```txt
# 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

---

<div class="post-metadata">

**Author:** ![saxosun](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/saxosun/32/9368_2.png) [@saxosun](https://get-help.theconstruct.ai/u/saxosun)\
**Post date:** [June 7, 2023, 2:24pm UTC](https://get-help.theconstruct.ai/t/custom-server-message/24769/3 "2023-06-07T14:24:33Z")

</div>

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:

> **[How to publish a dictionary with other dictionary inside in a topic? - ROS...](https://answers.ros.org/question/307584/how-to-publish-a-dictionary-with-other-dictionary-inside-in-a-topic/)**
>
> Hi all, I'm trying to publish in a topic a dictionary with other dictionary inside so other ROS node is able to access to that information, but I do not know how can I do it. Anyone has any idea? Thanks for your help!

Thanks and Regards  
Salvatore

---

<div class="post-metadata">

**Author:** ![system](https://get-help.theconstruct.ai/uploads/default/original/2X/9/9d3ce8305cc0d0d9b6e07d15767a6f245c526f1b.jpeg) [@system](https://get-help.theconstruct.ai/u/system)\
**Post date:** [June 12, 2023, 2:25pm UTC](https://get-help.theconstruct.ai/t/custom-server-message/24769/4 "2023-06-12T14:25:27Z")

</div>

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