int () { int peekStack = stack[stackSize - 1]; if (peekStack == JsonScope.EMPTY_ARRAY) { stack[stackSize - 1] = JsonScope.NONEMPTY_ARRAY; } else if (peekStack == JsonScope.NONEMPTY_ARRAY) { // Look for a comma before the next element. int c = nextNonWhitespace(true); switch (c) { case ']': return peeked = PEEKED_END_ARRAY; case ';': checkLenient(); // fall-through case ',': break; default: throw createParseError("Unterminated array"); } } else if (peekStack == JsonScope.EMPTY_OBJECT || peekStack == JsonScope.NONEMPTY_OBJECT) { stack[stackSize - 1] = JsonScope.DANGLING_NAME; // Look for a comma before the next element. if (peekStack == JsonScope.NONEMPTY_OBJECT) { int c = nextNonWhitespace(true); switch (c) { case '}': return peeked = PEEKED_END_OBJECT; case ';': checkLenient(); // fall-through case ',': break; default: throw createParseError("Unterminated object"); } } int c = nextNonWhitespace(true); return peeked = switch (c) { case '"' -> PEEKED_DOUBLE_QUOTED_NAME; case '\'' -> { checkLenient(); yield PEEKED_SINGLE_QUOTED_NAME; } case '}' -> { if (peekStack != JsonScope.NONEMPTY_OBJECT) { yield PEEKED_END_OBJECT; } else { throw createParseError("Expected name"); } } default -> { checkLenient(); position--; // Don't consume the first character in an unquoted string. if (isLiteral((char)c)) { yield PEEKED_UNQUOTED_NAME; } else { throw createParseError("Expected name"); } } }