@@ -222,8 +222,10 @@ public JsonDocumentItemType next() {
222222 }
223223 }
224224 }
225- // no way we get here.
226- return null ;
225+ throw new IllegalStateException ( "unexpected end of JSON [" +
226+ this .jsonString .substring ( this .jsonValueStart ,this .jsonValueEnd )+
227+ "] in current processing state " +
228+ this .processingStates .getCurrent () );
227229 }
228230
229231 /**
@@ -295,31 +297,17 @@ private void moveTo(char character) throws IllegalStateException {
295297 throw new IllegalStateException ("character [" + character + "] is not the next non-blank character" );
296298 }
297299
298- /**
299- * Goes through the JSON string to locate a non-escaped instance of a given character.
300- * Ex: on 'AB\"C"' this method returns 5 (not 3)
301- *
302- * @param character character to be found
303- * @return the position of the character or -1 if not found.
304- */
305- private int locateCharacter (char character ) {
300+ private int nextQuote () {
306301 int pointer = this .position ;
307302
308303 while ( pointer < this .limit ) {
309304 final char c = this .jsonString .charAt ( pointer );
310305 if (c == ESCAPE_CHAR ) {
311- // We encountered an escape character.
312- // We should just skip the next one as it is either the expected character
313- // but as escaped one, we should ignore it, either this is something else
314- // and we should ignore it also
315- pointer += 2 ;
316- continue ;
306+ pointer ++;
317307 }
318- else {
319- if ( c == character ) {
320- // found
321- return pointer ;
322- }
308+ else if (c == '"' ) {
309+ // found
310+ return pointer ;
323311 }
324312 pointer ++;
325313 }
@@ -366,7 +354,7 @@ private void consumeQuotedString() {
366354 this .position ++;
367355
368356 //locate ending quote
369- int endingQuote = locateCharacter ( StringJsonDocumentMarker . QUOTE . getMarkerCharacter () );
357+ int endingQuote = nextQuote ( );
370358 if (endingQuote == -1 ) {
371359 throw new IllegalStateException ("Can't find ending quote of key name" );
372360 }
0 commit comments