Decode JSON-formatted text
value =
jsondecode(text)
JSON supports fewer data types than MATLAB. jsondecode
converts
JSON data types to the MATLAB data types in this table. jsondecode
converts
JSON object field names to MATLAB structure field names.
JSON Data Type | MATLAB Data Type |
---|---|
null, in numeric arrays | NaN |
null, in nonnumeric arrays | Empty |
Boolean | Scalar |
Number | Scalar |
String | Character vector |
Object (In JSON, object means an unordered set of name-value pairs.) | Scalar structure (Names are made valid using |
Array, when elements are of different data types | Cell array |
Array of booleans | Array of |
Array of numbers | Array of |
Array of strings | Cell array of character vectors |
Array of objects — Same field names | Structure array |
Array of objects — Different field names | Cell array of scalar structures |