(Server agnostic question, but I am interested if it differs depending on the server software.)
I was recently told that we needed to change back end requests from
JSON.stringify(object) with a content type of
text/plain to just
object with a content type of
application/json. I am all for this due to technical correctness of identifying the data.
However, the reasoning was that this would provide performance benefits by alleviating the need to
JSON.parse the string that is received.
It is my understanding that no matter what content type you send, it is still a string being received by the server. In the world of 0's and 1's of data transmission, there is no distinction between a JSON object and a string. I believe that when the server receives a Content-Type application/json, it just calls
JSON.parse before passing the data to your application -- meaning there is no performance benefit to using one over the other, because they are doing the same thing.
Is my interpretation correct, or is the server somehow able to handle one content type faster than the other?