Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with table data #29

Closed
pjkoprowski opened this issue Oct 3, 2016 · 2 comments
Closed

Error with table data #29

pjkoprowski opened this issue Oct 3, 2016 · 2 comments

Comments

@pjkoprowski
Copy link

@fangq

An indexing error occurs when parsing table data using savejson.m

For instance, if one calls the following:

>> j = savejson('test_data', open('census1994.mat'), 'test.json');

you get the following error:

Error using savejson>matlabobject2json (line 444)
You cannot subscript a table using only one subscript. Table subscripting requires both row and variable subscripts.

Error in savejson>obj2json (line 175)
txt=matlabobject2json(name,item,level,varargin{:});

Error in savejson>struct2json (line 285)
txt{end+1}=obj2json(names{e},item(i,j).(names{e}),...

Error in savejson>obj2json (line 171)
txt=struct2json(name,item,level,varargin{:});

Error in savejson (line 140)
json=obj2json(rootname,obj,rootlevel,opt);

I hacked a solution, but I'm not sure if this leads to more issues with other files. See attached.

Cheers,

Paul
paul_savejson.txt

@hillsm
Copy link

hillsm commented Nov 9, 2017

@paul

Your solution works in R2015b, but not in later versions. Moreover, table properties (like RowNames) are not preserved.

Greetings,

Michel

@fangq fangq closed this as completed in 1597106 Jul 12, 2018
@fangq
Copy link
Member

fangq commented Jul 12, 2018

sorry @pjkoprowski and @hillsm for the long delay in processing this issue. I patched savejson with Paul's patch, and I also added support for RowNames, but in the current code, neither the VariableNames nor RowNames allows to have space or other non-variable-name strings.

In the future, need to move valid_field() from loadjson to a separate unit and use it to convert Table name fields.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants