Saves a struct to a JSON format string. The string can be load by the jsonloads command.
Syntax |
Description |
---|---|
out = jsonsaves(struct); |
Saves the struct to a JSON format string. The string can be load by the jsonloads command. |
out = jsonsaves(); |
Saves all the variables in the Script Workspace to a JSON format string. |
Example
The following code example shows how to save the struct "a" to a JSON format string "str1".
a = {"b": [1, 2, 3], "c" : "a string"};
str1 = jsonsaves(a);
The string "str1" is:
?str1;
{ "a" : { "b" :
{
"_complex" : false,
"_data" : [ 1, 2, 3 ],
"_size" : [ 1, 3 ],
"_type" : "matrix"
},
"c" : "a string"
} }
The following code example shows how to load the JSON format string "str1" to the Script Workspace:
jsonloads(str1);
See Also