Java code for JSON Response Format ExampleThis Java code snippet was generated automatically for the JSON Response Format example.
<< Back to the JSON Response Format example
What is JSON?
Why specify the correct content type for JSON response?
Each HTTP resource has a media type, or MIME type, which describes the resource type and allows browsers and servers to understand it properly. As an example, if the server is capable of accepting both JSON and XML content types on one endpoint, a "Content-Type: application/json" will tell the server to interpret the body data as JSON, whereas a "Content-Type: application/xml" will tell the server to interpret the body data as XML.
JSON Response Format Example
To get the response format, we first need to send a request to the ReqBin echo URL:
The server returning our JSON Response Format: