Skip to content

Commit

Permalink
complete data compression support, close #52
Browse files Browse the repository at this point in the history
  • Loading branch information
Qianqian Fang committed Apr 28, 2019
1 parent 804115b commit 0d61c4b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 9 additions & 4 deletions savejson.m
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,11 @@
end
try
error(javachk('jvm'));
matlab.net.base64decode('test');
try
base64decode('test');
catch
matlab.net.base64decode('test');
end
catch
error('java-based compression is not supported');
end
Expand Down Expand Up @@ -391,6 +395,10 @@
dozip=jsonopt('Compression','',varargin{:});
zipsize=jsonopt('CompressArraySize',100,varargin{:});

if(islogical(item))
item=uint8(item);
end

if(length(size(item))>2 || issparse(item) || ~isreal(item) || ...
(isempty(item) && any(size(item))) ||jsonopt('ArrayToStruct',0,varargin{:}) || (~isempty(dozip) && numel(item)>zipsize))
if(isempty(name))
Expand Down Expand Up @@ -471,9 +479,6 @@
if(~isempty(dozip) && numel(item)>zipsize)
if(isreal(item))
fulldata=item(:)';
if(islogical(fulldata))
fulldata=int32(fulldata);
end
else
txt=sprintf(dataformat,txt,padding0,'"_ArrayIsComplex_": ','1', sep);
fulldata=[real(item(:)) imag(item(:))];
Expand Down
2 changes: 1 addition & 1 deletion struct2jdata.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
fn=fieldnames(data);
newdata=data;
len=length(data);
needbase64=jsonopt('Base64',0,varargin{:});
needbase64=jsonopt('Base64',1,varargin{:});
if(jsonopt('Recursive',0,varargin{:})==1)
for i=1:length(fn) % depth-first
for j=1:len
Expand Down

0 comments on commit 0d61c4b

Please sign in to comment.