public String nextString(){
  nextClean('"');
  StringBuilder sb=new StringBuilder();
  for (; ; ) {
    char c=next();
switch (c) {
case 0:
case '\n':
case '\r':
      throw syntaxError("Unterminated string");
case '\\':
    c=next();
switch (c) {
case 'b':
    sb.append('\b');
  break;
case 't':
sb.append('\t');
break;
case 'n':
sb.append('\n');
break;
case 'f':
sb.append('\f');
break;
case 'r':
sb.append('\r');
break;
case 'u':
sb.append((char)Integer.parseInt(next(4),16));
break;
default :
sb.append(c);
}
break;
case '"':
return sb.toString();
default :
if (c < ' ') {
throw syntaxError("Unescaped control character (ascii " + ((int)c) + ") in string");
}
sb.append(c);
break;
}
}
}

public String nextString ( ) { nextClean ( '"' ) ; StringBuilder sb = new StringBuilder ( ) ; for ( ; ; ) { char c = next ( ) ; switch ( c ) { case 0 : case '\n' : case '\r' : throw syntaxError ( "Unterminated string" ) ; case '\\' : c = next ( ) ; switch ( c ) { case 'b' : sb . append ( '\b' ) ; break ; case 't' : sb . append ( '\t' ) ; break ; case 'n' : sb . append ( '\n' ) ; break ; case 'f' : sb . append ( '\f' ) ; break ; case 'r' : sb . append ( '\r' ) ; break ; case 'u' : sb . append ( ( char ) Integer . parseInt ( next ( 4 ) , 16 ) ) ; break ; default : sb . append ( c ) ; } break ; case '"' : return sb . toString ( ) ; default : if ( c < ' ' ) { throw syntaxError ( "Unescaped control character (ascii " + ( ( int ) c ) + ") in string" ) ; } sb . append ( c ) ; break ; } } }
return the characters up to the next close quote character . backslash processing is done . the formal json format does not allow strings in single quotes , but an implementation is allowed to accept them .
