Skip to content
Snippets Groups Projects
Commit 25ad795a authored by Qianqian Fang's avatar Qianqian Fang
Browse files

unescape string in fast array parser mode

parent 30a842ee
Branches
Tags
No related merge requests found
......@@ -223,6 +223,9 @@ function object = parse_array(inStr, esc, varargin) % JSON array is written in r
arraystr=regexprep(arraystr,'\"','''');
end
object=eval(arraystr);
if(iscell(object))
object=cellfun(@unescapejsonstring,object,'UniformOutput',false);
end
pos=endpos;
catch
while 1
......@@ -510,8 +513,11 @@ end
function newstr=unescapejsonstring(str)
newstr=str;
if(~ischar(str))
return;
end
escapechars={'\\','\"','\/','\a','\b','\f','\n','\r','\t','\v'};
for i=1:length(escapechars);
newstr=regexprep(newstr,regexprep(escapechars{i},'\\','\\\\'), escapechars{i});
end
newstr=regexprep(newstr,'\\\\(u[0-9a-fA-F]{4}[^0-9a-fA-F]*)','\\$1');
\ No newline at end of file
newstr=regexprep(newstr,'\\u([0-9A-Fa-f]{4})', '${char(base2dec($1,16))}');
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment