Why is message content JSON encoded in pubsub?

Viewed 94

I'm currently working on implementing a Pub/Sub pattern for a project I'm working on and I was wondering why the content was JSON encoded string when the rest of the message was in plain JSON.

I couldn't find any documentation on this topic, generic documentation on the Pub/Sub pattern is not really abundant, or I didn't use the good search terms.

1 Answers

If content was not encoded separately like that, then the server would need to be aware of the contents of the message in order to deserialize. With this approach, it can simply treat the content as a string and forward that encoded string along to subscribers.

Related