Package: matlab.net.http.io
Superclasses: matlab.net.http.io.StringConsumer
Content consumer that converts JSON input into MATLAB data
This ContentConsumer
receives messages whose content is JSON. It converts
the JSON data to MATLAB® and stores the result in the body of the response message.
This consumer should only be applied to incoming content that is JSON (for example,
response messages or parts of multipart messages with a Content-Type of
"application/json"
), though it does not check the incoming
Content-Type.
By default, MATLAB automatically converts a message with a Content-Type
"application/json"
, so you do not need to specify this consumer for that
type, or any other type that obviously indicates JSON. For more information, see input
conversions for MessageBody.Data
. Specify this provider explicitly if you
know that the incoming data is JSON even if the Content-Type might not indicate this. For
example, sometimes a file containing JSON data has a name with a .txt
extension. When downloading such a file the server might specify a Content-Type of
"text/plain"
based on that extension, even though it contains JSON
data.
If an error occurs converting the data, Response.Body.Data
in the
HTTPException
thrown on the error contains any intermediate result of the
decoding process.
The matlab.net.http.io.JSONConsumer
class is a handle
class.
consumer = JSONConsumer
creates a consumer that converts a JSON
string received in a ResponseMessage
to MATLAB data using jsondecode
.
ContentConsumer
| jsondecode
| JSONProvider
| MessageBody
| StringConsumer