private void beforeKey ( ) throws JSONException { Scope context = peek ( ) ; if ( context == Scope . NONEMPTY_OBJECT ) { // first in object out . append ( ' ' ) ; } else if ( context != Scope . EMPTY_OBJECT ) { // not in an object! throw new JSONException ( "Nesting problem" ) ; } newline ( ) ; replaceTop ( Scope . DANGLING_KEY ) ; }
Inserts any necessary separators and whitespace before a name . Also adjusts the stack to expect the key s value .