diff --git a/loadjson.m b/loadjson.m index 7f9a796..68e995d 100644 --- a/loadjson.m +++ b/loadjson.m @@ -223,6 +223,9 @@ 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 @@ function error_pos(msg, inStr) 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