matlab.net.http.HeaderField.convertLike - Convert header field value like another header field - MATLAB (original) (raw)
Main Content
Class: matlab.net.http.HeaderField
Namespace: matlab.net.http
Convert header field value like another header field
Syntax
Description
[value](#bvc9369-1-value) = convertLike([fields](#bvc9369-1-fields),[other](#bvc9369-1-other))
converts the Value
property of each element of fields
to a MATLABĀ® type, using conversion rules of the field other
.
For each header field in fields
, MATLAB checks the matlab.net.http.field
namespace for a class that supports a name with the same value as the fields.Name
property. If the namespace contains a class for this field, then convert
invokes the convert
method of that class. To see the classes in thefield
namespace, call thematlab.net.http.HeaderField.displaySubclasses
method.
If the conversion fails or if no class supports one of the fields.Name
properties, then convertLike
throws an exception.
This method does not support heterogeneous arrays. All members of fields
must be the same class.
Input Arguments
Field to use for conversion rules, specified as string, character vector,HeaderField
object, or matlab.metadata.Class
identifying a HeaderField
subclass in thematlab.net.http.field
namespace.
Output Arguments
Header field values, returned as a vector of MATLAB types. The types returned depend on the value of the specific class convert
method.
Examples
The response
variable is a message that has a Created-Date
header field. Its value is formatted like an HTTPDateField
object, which returns a datetime
object.
myField = response.getFields('Created-Date'); date = myField.convertLike(?matlab.net.http.field.HTTPDateField);
Version History
Introduced in R2016b