json_message_converter.py
Go to the documentation of this file.
1 import json
2 from rospy_message_converter import message_converter
3 
4 def convert_json_to_ros_message(message_type, json_message):
5  """
6  Takes in the message type and a JSON-formatted string and returns a ROS
7  message.
8 
9  Example:
10  message_type = "std_msgs/String"
11  json_message = '{"data": "Hello, Robot"}'
12  ros_message = convert_json_to_ros_message(message_type, json_message)
13  """
14  dictionary = json.loads(json_message)
15  return message_converter.convert_dictionary_to_ros_message(message_type, dictionary)
16 
18  """
19  Takes in a ROS message and returns a JSON-formatted string.
20 
21  Example:
22  ros_message = std_msgs.msg.String(data="Hello, Robot")
23  json_message = convert_ros_message_to_json(ros_message)
24  """
25  dictionary = message_converter.convert_ros_message_to_dictionary(message)
26  json_message = json.dumps(dictionary)
27  return json_message
def convert_json_to_ros_message(message_type, json_message)


rospy_message_converter
Author(s): Brandon Alexander
autogenerated on Tue May 7 2019 03:17:53