public void parse ( ) throws EOFException { if ( ! startedStreaming && levelStack . isEmpty ( ) ) { readNextChar ( null ) ; switch ( currentChar ) { case ( byte ) 0xEF : pushLevel ( Mode . BOM ) ; break ; case O_CURLY : pushLevel ( Mode . JSON_OBJECT ) ; break ; case O_SQUARE : pushLevel ( Mode . JSON_ARRAY ) ; break ; default : throw new IllegalStateException ( "Only UTF-8 is supported" ) ; } startedStreaming = true ; } while ( true ) { if ( levelStack . isEmpty ( ) ) { return ; //nothing more to do } JsonLevel currentLevel = levelStack . peek ( ) ; switch ( currentLevel . peekMode ( ) ) { case BOM : readBOM ( ) ; break ; case JSON_OBJECT : readObject ( currentLevel ) ; break ; case JSON_ARRAY : readArray ( currentLevel ) ; break ; case JSON_OBJECT_VALUE : case JSON_ARRAY_VALUE : case JSON_STRING_HASH_KEY : case JSON_STRING_VALUE : case JSON_BOOLEAN_TRUE_VALUE : case JSON_BOOLEAN_FALSE_VALUE : case JSON_NUMBER_VALUE : case JSON_NULL_VALUE : readValue ( currentLevel ) ; break ; } } }
Instructs the parser to start parsing the current buffer .