Hacker News new | ask | show | jobs
by Zekio 3400 days ago
Their JSON have an key called payload which saves a String rather than an Object, is there any benefits to doing this? since they also escape the " in the String
2 comments

Probably that services aren't required to use JSON (since they use many different service languages, it's not unlikely that they use many different serialisation methods - JSON, protobuf, etc.)
Exactly this - each publisher can encode their own payload, including protobufs, JSON, plain text or base64'd binaries. RMS itself is completely oblivious to the format of payload used in the message.
Separation of concerns: the code handling the envelope doesn't need to know about the format of the payload. The JSON in that payload will only be encoded (on the sender) and decoded (on the recipient) once.