package jsoniter

// ReadArray read array element, tells if the array has more element to read.
func ( *Iterator) () ( bool) {
	 := .nextToken()
	switch  {
	case 'n':
		.skipThreeBytes('u', 'l', 'l')
		return false // null
	case '[':
		 = .nextToken()
		if  != ']' {
			.unreadByte()
			return true
		}
		return false
	case ']':
		return false
	case ',':
		return true
	default:
		.ReportError("ReadArray", "expect [ or , or ] or n, but found "+string([]byte{}))
		return
	}
}

// ReadArrayCB read array with callback
func ( *Iterator) ( func(*Iterator) bool) ( bool) {
	 := .nextToken()
	if  == '[' {
		if !.incrementDepth() {
			return false
		}
		 = .nextToken()
		if  != ']' {
			.unreadByte()
			if !() {
				.decrementDepth()
				return false
			}
			 = .nextToken()
			for  == ',' {
				if !() {
					.decrementDepth()
					return false
				}
				 = .nextToken()
			}
			if  != ']' {
				.ReportError("ReadArrayCB", "expect ] in the end, but found "+string([]byte{}))
				.decrementDepth()
				return false
			}
			return .decrementDepth()
		}
		return .decrementDepth()
	}
	if  == 'n' {
		.skipThreeBytes('u', 'l', 'l')
		return true // null
	}
	.ReportError("ReadArrayCB", "expect [ or n, but found "+string([]byte{}))
	return false
}