Skip to content

savejson incorrectly stores matrix data #54

@stephen-young

Description

@stephen-young

When loading a matrix from a json file with the loadjson function that was generated from the savejson function, it comes in as the transpose of the original rather than being identical to the original.

The following code:

%% ArrayTest
bar = magic(4);
[~] = savejson('',bar,'bar.json');
test = loadjson('bar.json');
result = all(test == bar,'all')
result = all(test == bar','all')

%% ArrayInStructTest
foo.bar = magic(4);
[~] = savejson('',foo,'foo.json');
test = loadjson('foo.json');
result = all(test.bar == foo.bar,'all')
result = all(test.bar == foo.bar','all')

returns:

result = 0
result = 1
result = 0
result = 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions