Reputation: 367
I am trying to understand whether the body of a HTTP request/response be encoded if the body content is JSON?
My understanding is that encoding is needed to escape characters that can potentially cause ambiguity in the HTTP request/response. I am not sure whether JSON body has the capability to do that.
Any help would be greatly appreciated.
Upvotes: 2
Views: 1878
Reputation: 71
If the request/response payload is valid JSON, then that implies that all "escape characters" are encoded as text that should not interfere with HTTP in any way. E.g., newlines encoded as "\n", nulls as "\u0000", etc.
So my short answer is that you don't need any further encoding for the sake of HTTP. If you're the one implementing the HTTP server or client, my longer answer is that Detect end of HTTP request body might be of interest too.
Upvotes: 3