public String nextString(char quote) throws JSONException {
  char c;
  StringBuffer sb=new StringBuffer();
  for (; ; ) {
    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;
case 'x':
sb.append((char)Integer.parseInt(next(2),16));
break;
default :
sb.append(c);
}
break;
default :
if (c == quote) {
return sb.toString();
}
sb.append(c);
}
}
}

public String nextString ( char quote ) throws JSONException { char c ; StringBuffer sb = new StringBuffer ( ) ; for ( ; ; ) { 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 ; case 'x' : sb . append ( ( char ) Integer . parseInt ( next ( 2 ) , 16 ) ) ; break ; default : sb . append ( c ) ; } break ; default : if ( c == quote ) { return sb . toString ( ) ; } sb . append ( c ) ; } } }
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 .
