matlab-json
matlab-json copied to clipboard
setjsonfield causes fatal exception in R2015b
The following code in MATLAB R2015b 64-bit on Windows causes a fatal exception (Access Violation).
matlab_object.a = 1;
setjsonfield(matlab_object, 'b', 'foo');
Also, when it does not cause a crash, it does nothing. For example, the following test case will pass.
matlab_object = struct();
setjsonfield(matlab_object, 'b', 'foo');
assert(isempty(fieldnames(matlab_object)))
I've tried recompiling the MEX function with no change. It seems likely that the new execution engine in R2014b prevents this kind of access.
Bummer.
Maybe tojson
then needs an optional argument for translation of field-names.
Note to self: check return value of mxAddField
, as -1
indicate an error.