code: @Override
    public JavaScriptObject nextJavaScriptObject( boolean useSafeEval ) {
      int p = peeked;
      if (p == PEEKED_NONE) {
        p = doPeek();
      }
  
      switch (p) {
      case PEEKED_BEGIN_OBJECT:
      case PEEKED_BEGIN_ARRAY:
        JavaScriptObject result;
        int peekStack = stack.get(stackSize - 1);
        if (peekStack == JsonScope.NONEMPTY_DOCUMENT) {
          // start of the document
          String toEval = in.getInput();
          result = useSafeEval ? JsonUtils.safeEval( toEval ) : JsonUtils.unsafeEval( toEval );
          // we read everything, we move the pointer to the end of the document
          pos = toEval.length();
          limit = toEval.length();
          peeked = PEEKED_NONE;
        } else {
          String toEval = nextValue();
          result = useSafeEval ? JsonUtils.safeEval( toEval ) : JsonUtils.unsafeEval( toEval );
        }
        return result;
      default:
        throw new IllegalStateException("Expected an array or object to evaluate a JavaScriptObject but was " + peek()
            + " at line " + getLineNumber() + " column " + getColumnNumber());
      }
    }
docs: {@inheritDoc}