Skip to content

Commit

Permalink
pass formatversion tag to jdatadecode
Browse files Browse the repository at this point in the history
  • Loading branch information
fangq committed Jun 11, 2019
1 parent e39254d commit ebbcfd2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions examples/demo_jsonlab_basic.m
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,21 @@

data2json=reshape(1:(2*4*6),[2,4,6]);
savejson('',data2json,'NestArray',1,'FormatVersion',1.8)
json2data=loadjson(ans,'FormatVersion',1.8)
if(any(json2data(:)~=data2json(:)) || any(size(json2data)~=size(data2json)))
warning('conversion does not preserve original data');
end

fprintf(1,'\n%%=================================================\n')
fprintf(1,'%% a 3-D array in annotated array form (JSONLab 1.9 or earlier)\n')
fprintf(1,'%%=================================================\n\n')

data2json=reshape(1:(2*4*6),[2,4,6]);
savejson('',data2json,'NestArray',0,'FormatVersion',1.8)
json2data=loadjson(ans,'FormatVersion',1.8)
if(any(json2data(:)~=data2json(:)) || any(size(json2data)~=size(data2json)))
warning('conversion does not preserve original data');
end

fprintf(1,'\n%%=================================================\n')
fprintf(1,'%% a complex number\n')
Expand Down
3 changes: 2 additions & 1 deletion loadjson.m
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,8 @@
end
pos=parse_char(inputstr, pos, '}');
if(isstruct(object) && jsonopt('JDataDecode',1,varargin{:})==1)
object=jdatadecode(object,struct('Recursive',0));
varargin{:}.Recursive=0;
object=jdatadecode(object,varargin{:});
end
end

Expand Down

0 comments on commit ebbcfd2

Please sign in to comment.