d = readdictionary(filename)
d = readdictionary(filename, Name, Value)
| Parameter | Description |
|---|---|
| filename | text scalar: source file name. |
| Parameter | Description |
|---|---|
| d | scalar: dictionary object. |
d = readdictionary(filename) reads a JSON object from filename and returns it as a dictionary.
JSON object member names become string dictionary keys. Values are converted to Nelson values. JSON arrays are decoded as cell column arrays. If the JSON values have mixed types or non-scalar sizes, the dictionary value type is cell.
d = readdictionary(filename, Name, Value) customizes the read operation. Supported options are:
'auto' and 'json'. Only JSON dictionary files are currently supported.true.true.NaN, Infinity, Inf, -Infinity, and -Inf tokens are accepted. Default is true.DictionaryNodeName and DictionarySelector are accepted as option names, but they are not supported for JSON dictionary files.
filename = [tempdir(), 'products.json'];
d = dictionary(["apple", "banana"], [1.2, 2.3]);
writedictionary(d, filename);
r = readdictionary(filename)
filename = [tempdir(), 'counts.json'];
filewrite(filename, '{"a": 1, "b": 2}');
d = readdictionary(filename, 'ValueType', 'single')
| Version | Description |
|---|---|
| 2.0.0 | initial version |