Skip to content

Commit 0d61c4b

Browse files
author
Qianqian Fang
committed
complete data compression support, close #52
1 parent 804115b commit 0d61c4b

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

savejson.m

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,11 @@
116116
end
117117
try
118118
error(javachk('jvm'));
119-
matlab.net.base64decode('test');
119+
try
120+
base64decode('test');
121+
catch
122+
matlab.net.base64decode('test');
123+
end
120124
catch
121125
error('java-based compression is not supported');
122126
end
@@ -391,6 +395,10 @@
391395
dozip=jsonopt('Compression','',varargin{:});
392396
zipsize=jsonopt('CompressArraySize',100,varargin{:});
393397

398+
if(islogical(item))
399+
item=uint8(item);
400+
end
401+
394402
if(length(size(item))>2 || issparse(item) || ~isreal(item) || ...
395403
(isempty(item) && any(size(item))) ||jsonopt('ArrayToStruct',0,varargin{:}) || (~isempty(dozip) && numel(item)>zipsize))
396404
if(isempty(name))
@@ -471,9 +479,6 @@
471479
if(~isempty(dozip) && numel(item)>zipsize)
472480
if(isreal(item))
473481
fulldata=item(:)';
474-
if(islogical(fulldata))
475-
fulldata=int32(fulldata);
476-
end
477482
else
478483
txt=sprintf(dataformat,txt,padding0,'"_ArrayIsComplex_": ','1', sep);
479484
fulldata=[real(item(:)) imag(item(:))];

struct2jdata.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
fn=fieldnames(data);
4343
newdata=data;
4444
len=length(data);
45-
needbase64=jsonopt('Base64',0,varargin{:});
45+
needbase64=jsonopt('Base64',1,varargin{:});
4646
if(jsonopt('Recursive',0,varargin{:})==1)
4747
for i=1:length(fn) % depth-first
4848
for j=1:len

0 commit comments

Comments
 (0)