Gazebo | Ignition | Community
Ask Your Question

Generic Pub / Sub; To and from JSON

asked 2018-12-17 16:57:00 -0600

prakash gravatar image

I am interested in subscribing to a set of topics, receiving messages and sending messages to topics. I have a generic subscription as void cb_generic(const std::string& _msg). The content of the string is protobuf binary message which I want to convert to JSON. Any suggestions or examples on how to accomplish this task? The steps I see are:

  1. Convert std::string to protobuf object
  2. Convert protobuf object to json.


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2018-12-18 09:59:58 -0600

nkoenig gravatar image

The first step would require deserialization of the binary message into a protobuf structure. Then you could translate the deserialized message into json. There might be libraries that can do the conversion for you. I think protobuf3 has support for json, but I haven't used that capability yet.

edit flag offensive delete link more


Thank you for taking the time to respond.

prakash gravatar imageprakash ( 2019-01-18 12:30:09 -0600 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2018-12-17 16:57:00 -0600

Seen: 83 times

Last updated: Dec 18 '18