Skip to content

Commit

Permalink
treat string array as cell array in newer matlab
Browse files Browse the repository at this point in the history
  • Loading branch information
fangq committed Mar 12, 2019
1 parent c3eb021 commit ed2645e
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions savejson.m
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,12 @@
%%-------------------------------------------------------------------------
function txt=obj2json(name,item,level,varargin)

if(iscell(item))
if(iscell(item) || isa(item,'string'))
txt=cell2json(name,item,level,varargin{:});
elseif(isstruct(item))
txt=struct2json(name,item,level,varargin{:});
elseif(ischar(item))
txt=str2json(name,item,level,varargin{:});
elseif(isa(item,'string'))
txt=str2json(name,item{:},level,varargin{:});
elseif(isobject(item))
if(~exist('OCTAVE_VERSION','builtin') && istable(item))
txt=matlabtable2json(name,item,level,varargin{:});
Expand All @@ -186,8 +184,8 @@
%%-------------------------------------------------------------------------
function txt=cell2json(name,item,level,varargin)
txt={};
if(~iscell(item))
error('input is not a cell');
if(~iscell(item) && ~isa(item,'string'))
error('input is not a cell or string array');
end

dim=size(item);
Expand Down

0 comments on commit ed2645e

Please sign in to comment.