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

savejson st issue in matlab 2017 #39

Closed
daeh opened this issue Jul 16, 2017 · 2 comments
Closed

savejson st issue in matlab 2017 #39

daeh opened this issue Jul 16, 2017 · 2 comments

Comments

@daeh
Copy link

daeh commented Jul 16, 2017

With the commands:

data = loadjson('{"Test": ["GML", "XML"]}')
json = savejson('',data)

'savejson' produces the error below in 2017b but not 2016b. I know this 2017 issue has come up before, but it's still an issue in the current release.

Undefined function or variable 'st'.
Error in savejson>matlabobject2json (line 448)
txt=struct2json(name,st,level,varargin{:});
Error in savejson>obj2json (line 175)
txt=matlabobject2json(name,item,level,varargin{:});
Error in savejson>cell2json (line 216)
txt{end+1}=obj2json(name,item{i,j},level+(dim(1)>1)+(len>bracketlevel),varargin{:});
Error in savejson>obj2json (line 169)
txt=cell2json(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);

@fangq
Copy link
Member

fangq commented Jul 20, 2017

hi, this bug was previously reported (Issue #34), and was fixed in the commit 86ef12a back in March.

can you check out the latest version, and try it again?

@fangq fangq closed this as completed Jul 20, 2017
@daeh
Copy link
Author

daeh commented Jul 20, 2017

Thanks for taking a look. I only pulled the repo this week so I don't know how I would have gotten an old version. With this version (in 2017b), there's now no error but the values get dropped

data = loadjson('{"Test": ["GML", "XML"]}')
json = savejson('',data)
data = 
  struct with fields:

    Test: {["GML"]  ["XML"]}
json =
    '{
     	"Test": [
     		{
     		},
     		{
     		}
     	]
     }
     '

Just as a sanity check, here's 2016b for comparison:

json = savejson('',data)
data = 
  struct with fields:

    Test: {'GML'  'XML'}
json =
{
	"Test": [
		"GML",
		"XML"
	]
}

I put the side by side progressions of obj2json in text files in case that's useful
2016b_out.txt
2017b_out.txt

For me, it's easy to fix if I just add isstring() conditions to ln. 172 and 313 of savejson
elseif(ischar(item)||isstring(item))
if(~ischar(item)&&~isstring(item))
Hopefully that doesn't mess anything else up
Thanks for the nice code!

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

2 participants