Convert any Octave obj into a compact JSON string.
toJSON strives to convert Octave vectors, matrices and/or ND arrays to equivalent JSON arrays. Special provisions are made to handle +/-Inf and complex numbers, which are conventionally not permitted is JSON string.
Input arguments:
"[octave_com_object]"
, and the contents are lost.
’[{"x": ..., "y": ...}, {"x": ..., "y": ...}]’
’{"x": [...], "y": [...]}’
Special cases:
The specification for JSON does not allow +/-Inf or complex numbers; nevertheless, provisions are made here to enable these important numbers:
{"re":..., "im":...}
Apparent JSON strings are left unquoted. This allows recursive use of toJSON. To prevent this, append a whitespace to the string.
The bodies of Octave inline functions are stored as string; however, reference to values external to inline function will be lost. e.g.
@(x) a*x => "@@(x) a*x"
See also: fromJSON.
Package: io