Skip to content

Commit

Permalink
avoid escaping base64 str, avoid double processing preencoded arrayzi…
Browse files Browse the repository at this point in the history
…pdata
  • Loading branch information
Qianqian Fang committed Oct 25, 2019
1 parent 4dc76ef commit cc4491d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
12 changes: 10 additions & 2 deletions savejson.m
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,11 @@
end
end
for e=1:len
val=escapejsonstring(item(e,:),varargin{:});
if(strcmp('_ArrayZipData_',decodevarname(name,varargin{1}.unpackhex))==0)
val=escapejsonstring(item(e,:),varargin{:});
else
val=item(e,:);
end
if(len==1)
obj=['"' decodevarname(name,varargin{1}.unpackhex) '": ' '"',val,'"'];
if(isempty(name))
Expand Down Expand Up @@ -533,7 +537,8 @@
isnest=varargin{1}.nestarray;

if(((isnest==0) && length(size(item))>2) || issparse(item) || ~isreal(item) || ...
(isempty(item) && any(size(item))) || varargin{1}.arraytostruct || (~isempty(dozip) && numel(item)>zipsize))
(isempty(item) && any(size(item))) || varargin{1}.arraytostruct || ...
(~isempty(dozip) && numel(item)>zipsize && strcmp('_ArrayZipData_',decodevarname(name,varargin{1}.unpackhex))==0))
if(isempty(name))
txt=sprintf('%s{%s%s"_ArrayType_": "%s",%s%s"_ArraySize_": %s,%s',...
padding1,nl,padding0,class(item),nl,padding0,regexprep(mat2str(size(item)),'\s+',','),nl);
Expand Down Expand Up @@ -750,6 +755,9 @@
%%-------------------------------------------------------------------------
function newstr=escapejsonstring(str,varargin)
newstr=str;
if(isempty(str) || isempty(regexp(str,'\W', 'once')))
return;
end
isoct=varargin{1}.isoctave;
if(isoct)
vv=sscanf(OCTAVE_VERSION,'%f');
Expand Down
3 changes: 2 additions & 1 deletion saveubjson.m
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,8 @@
isnest=1;
end
if((length(size(item))>2 && isnest==0) || issparse(item) || ~isreal(item) || ...
varargin{1}.arraytostruct || (~isempty(dozip) && numel(item)>zipsize))
varargin{1}.arraytostruct || (~isempty(dozip) && numel(item)>zipsize ...
&& strcmp('_ArrayZipData_',decodevarname(name,varargin{:}))==0))
cid=I_(uint32(max(size(item))),Imarker,varargin{:});
if(isempty(name))
txt=[Omarker{1} N_('_ArrayType_'),S_(class(item)),N_('_ArraySize_'),I_a(size(item),cid(1),Imarker,varargin{:}) ];
Expand Down

0 comments on commit cc4491d

Please sign in to comment.