String readString ( ) throws IOException { StringBuilder sb = new StringBuilder ( 50 ) ; // first char must be ": char ch = reader . next ( ) ; if ( ch != ' ' ) { throw new JsonParseException ( "Expected \" but actual is: " + ch , reader . readed ) ; } for ( ; ; ) { ch = reader . next ( ) ; if ( ch == ' ' ) { // escape: \" \\ \/ \b \f \n \r \t char ech = reader . next ( ) ; switch ( ech ) { case ' ' : sb . append ( ' ' ) ; break ; case ' ' : sb . append ( ' ' ) ; break ; case ' ' : sb . append ( ' ' ) ; break ; case ' ' : sb . append ( ' ' ) ; break ; case ' ' : sb . append ( ' ' ) ; break ; case ' ' : sb . append ( ' ' ) ; break ; case ' ' : sb . append ( ' ' ) ; break ; case ' ' : sb . append ( ' ' ) ; break ; case ' ' : // read an unicode uXXXX: int u = 0 ; for ( int i = 0 ; i < 4 ; i ++ ) { char uch = reader . next ( ) ; if ( uch >= ' ' && uch <= ' ' ) { u = ( u << 4 ) + ( uch - ' ' ) ; } else if ( uch >= ' ' && uch <= ' ' ) { u = ( u << 4 ) + ( uch - ' ' ) + 10 ; } else if ( uch >= ' ' && uch <= ' ' ) { u = ( u << 4 ) + ( uch - ' ' ) + 10 ; } else { throw new JsonParseException ( "Unexpected char: " + uch , reader . readed ) ; } } sb . append ( ( char ) u ) ; break ; default : throw new JsonParseException ( "Unexpected char: " + ch , reader . readed ) ; } } else if ( ch == ' ' ) { // end of string: break ; } else if ( ch == ' ' || ch == ' ' ) { throw new JsonParseException ( "Unexpected char: " + ch , reader . readed ) ; } else { sb . append ( ch ) ; } } return sb . toString ( ) ; }
read string like a encoded \ u0098 \ str