matlab-json icon indicating copy to clipboard operation
matlab-json copied to clipboard

setjsonfield causes fatal exception in R2015b

Open jamesmyatt opened this issue 9 years ago • 2 comments

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.

jamesmyatt avatar Sep 10 '15 10:09 jamesmyatt

Bummer.

Maybe tojson then needs an optional argument for translation of field-names.

christianpanton avatar Sep 10 '15 19:09 christianpanton

Note to self: check return value of mxAddField, as -1 indicate an error.

christianpanton avatar Nov 05 '15 15:11 christianpanton