Fix json parser special chars
This commit is contained in:
parent
5be25735ae
commit
c2e9e9e5bf
1 changed files with 17 additions and 17 deletions
|
@ -29,7 +29,22 @@ public class JsonTokenizer extends Tokenizer{
|
||||||
for(; j < line.length(); j++){
|
for(; j < line.length(); j++){
|
||||||
c = line.charAt(j);
|
c = line.charAt(j);
|
||||||
if(c == '\\'){
|
if(c == '\\'){
|
||||||
buffer+=c+line.charAt(++j);
|
c = line.charAt(++j);
|
||||||
|
switch(c){
|
||||||
|
case 'n':
|
||||||
|
buffer+='\n';
|
||||||
|
break;
|
||||||
|
case 'r':
|
||||||
|
buffer+='\r';
|
||||||
|
break;
|
||||||
|
case 't':
|
||||||
|
buffer+='\t';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
buffer+=c;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
if(c == '\"') break;
|
if(c == '\"') break;
|
||||||
buffer+=c;
|
buffer+=c;
|
||||||
|
@ -38,21 +53,6 @@ public class JsonTokenizer extends Tokenizer{
|
||||||
i=j;
|
i=j;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(c == '\''){
|
|
||||||
String buffer = "";
|
|
||||||
int j = i+1;
|
|
||||||
for(; j < line.length(); j++){
|
|
||||||
c = line.charAt(j);
|
|
||||||
if(c == '\\'){
|
|
||||||
buffer+=c+line.charAt(++j);
|
|
||||||
}
|
|
||||||
if(c == '\'') break;
|
|
||||||
buffer+=c;
|
|
||||||
}
|
|
||||||
getTokens().add(new Token(1, i+1, buffer, TokenType.CHAR));
|
|
||||||
i=j;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
getTokens().add(new Token(1, i+1, ""+c, TokenType.DELIMITER));
|
getTokens().add(new Token(1, i+1, ""+c, TokenType.DELIMITER));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue