public String nextString ( ) { nextClean ( ' ' ) ; StringBuilder sb = new StringBuilder ( ) ; for ( ; ; ) { char c = next ( ) ; switch ( c ) { case 0 : case ' ' : case ' ' : throw syntaxError ( "Unterminated string" ) ; case ' ' : c = next ( ) ; switch ( c ) { case ' ' : sb . append ( ' ' ) ; break ; case ' ' : sb . append ( ' ' ) ; break ; case ' ' : sb . append ( ' ' ) ; break ; case ' ' : sb . append ( ' ' ) ; break ; case ' ' : sb . append ( ' ' ) ; break ; case ' ' : 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 .