Writes the provided argument in a JSON formatted string. The string can be read back by the jsonreads command.
Syntax |
Description |
---|---|
out = jsonwrites(argument); |
Writes the provided argument in a JSON formatted string. The string can be read by the jsonreads command. The single argument must evaluate to either a Lumerical struct, cell, matrix, or string. |
Example
The following code example shows how to save the struct "a" to a JSON list "str1".
a = {"b": {1, 2, 3}};
str1 = jsonwrites(a);
The string "str1" is:
?str1; {
"b" : [ 1.0, 2.0, 3.0 ]
}
The following code example shows how to read the JSON list "str1" to the variable "b":
b = jsonreads(str1);
The struct to save to a JSON list can be defined in the line:
?jsonwrites(2); 2.0
?jsonwrites({1,2,3}); [1.0, 2.0, 3.0]
?jsonwrites('test'); "test"
?jsonwrites({'foo': 'bar'}); { "foo": "bar" }
See Also
jsonsave, jsonloads, jsonsaves, jsonread, jsonwrite, jsonreads, JSON files