writedictionary(d, filename)
writedictionary(d, filename, Name, Value)
| Parameter | Description |
|---|---|
| d | scalar: configured dictionary object. |
| filename | text scalar: destination file name. |
writedictionary(d, filename) writes the configured dictionary d to a JSON file.
Dictionary keys are written as JSON object member names. Keys must be text, numeric, or logical scalar values. Values can be scalar values, arrays, cell arrays, structures, or structure arrays when they can be represented as JSON values.
writedictionary(d, filename, Name, Value) customizes the write operation. Supported options are:
'auto' and 'json'. Only JSON dictionary files are currently supported.true.NaN, Infinity, and -Infinity tokens for non-finite numeric values. Default is true.MAT and NH5 persistence for dictionary variables is handled by savemat/loadmat and savenh5/loadnh5.
filename = [tempdir(), 'products.json'];
d = dictionary(["apple", "banana"], [1.2, 2.3]);
writedictionary(d, filename);
r = readdictionary(filename)
filename = [tempdir(), 'mixed_dictionary.json'];
d = dictionary(["vector", "data"], {[1 NaN Inf], struct('name', "Nelson")});
writedictionary(d, filename, 'PrettyPrint', false);
r = readdictionary(filename)
| Version | Description |
|---|---|
| 2.0.0 | initial version |