// ArrayOmitEmpty adds an array or slice to be encoded, must be used inside a slice or array encoding (does not encode a key)
// value must implement Marshaler
483864
func (enc *Encoder) ArrayOmitEmpty(v MarshalerJSONArray) {
	if v.IsNil() {
		return
	}
	enc.grow(4)
	r := enc.getPreviousRune()
	if r != '[' {
		enc.writeByte(',')
	}
	enc.writeByte('[')
	v.MarshalJSONArray(enc)
	enc.writeByte(']')
}
63792
func (enc *Encoder) Array(v MarshalerJSONArray) {
	if v.IsNil() {
		enc.grow(3)
		r := enc.getPreviousRune()
		if r != '[' {
			enc.writeByte(',')
		}
		enc.writeByte('[')
		enc.writeByte(']')
		return
	}
	enc.grow(100)
	r := enc.getPreviousRune()
	if r != '[' {
		enc.writeByte(',')
	}
	enc.writeByte('[')
	v.MarshalJSONArray(enc)
	enc.writeByte(']')
}
418822
func (b *Builder) closeEmptyArrayOrObject(tos ValueLength, isArray bool) {
	// empty Array or Object
	if isArray {
		b.buf[tos] = 0x01
	} else {
		b.buf[tos] = 0x0a
	}
	vpackAssert(b.buf.Len() == tos+9)
	b.buf.Shrink(8)
	b.stack.Pop()
}
292108
func IsEmpty(expr interface{}) bool {
	if expr == nil {
		return true
	}

	switch v := expr.(type) {
	case bool:
		return !v
	case int:
		return 0 == v
	case int8:
		return 0 == v
	case int16:
		return 0 == v
	case int32:
		return 0 == v
	case int64:
		return 0 == v
	case uint:
		return 0 == v
	case uint8:
		return 0 == v
	case uint16:
		return 0 == v
	case uint32:
		return 0 == v
	case uint64:
		return 0 == v
	case string:
		return len(v) == 0
	case float32:
		return 0 == v
	case float64:
		return 0 == v
	case time.Time:
		return v.IsZero()
	case *time.Time:
		return v.IsZero()
	}

	// 符合 IsNil 条件的，都为 Empty
	if IsNil(expr) {
		return true
	}

	// 长度为 0 的数组也是 empty
	v := reflect.ValueOf(expr)
	switch v.Kind() {
	case reflect.Slice, reflect.Map, reflect.Array, reflect.Chan:
		return 0 == v.Len()
	}

	return false
}
383715
func (enc *Encoder) SQLNullFloat64OmitEmpty(v *sql.NullFloat64) {
	if v != nil && v.Valid && v.Float64 != 0 {
		enc.Float64(v.Float64)
	}
}
611838
func IsEmpty(val reflect.Value) bool {
	valType := val.Kind()
	switch valType {
	case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
		return val.Int() == 0
	case reflect.Float32, reflect.Float64:
		return val.Float() == 0
	case reflect.String:
		return val.String() == ""
	case reflect.Interface, reflect.Slice, reflect.Ptr, reflect.Map, reflect.Chan, reflect.Func:
		// Check for empty slices and props
		if val.IsNil() {
			return true
		} else if valType == reflect.Slice || valType == reflect.Map {
			return val.Len() == 0
		}
	case reflect.Struct:
		fieldCount := val.NumField()
		for i := 0; i < fieldCount; i++ {
			field := val.Field(i)
			if field.IsValid() && !IsEmpty(field) {
				return false
			}
		}
		return true
	default:
		return false
	}
	return false
}
892810
func floatsToEmpties(arr []float64) []interface{} {
	ret := make([]interface{}, len(arr))
	for i, f := range arr {
		ret[i] = f
	}
	return ret
}
982560
func (enc *Encoder) SQLNullInt64OmitEmpty(v *sql.NullInt64) {
	if v != nil && v.Valid && v.Int64 != 0 {
		enc.Int64(v.Int64)
	}
}
1122190
func (enc *Encoder) AddInt32KeyOmitEmpty(key string, v int32) {
	enc.Int64KeyOmitEmpty(key, int64(v))
}
242792
func (enc *Encoder) AddSQLNullInt64OmitEmpty(v *sql.NullInt64) {
	if v != nil && v.Valid && v.Int64 != 0 {
		enc.Int64OmitEmpty(v.Int64)
	}
}
1007699
func (d *decodeState) arrayInterface() []interface{} {
	var v = make([]interface{}, 0)
	for {
		// Look ahead for ] - can only happen on first iteration.
		op := d.scanWhile(ScanSkipSpace)
		if op == ScanEndArray {
			break
		}

		// Back up so d.value can have the byte we just read.
		d.off--
		d.scan.undo(op)

		v = append(v, d.valueInterface())

		// Next token must be , or ].
		op = d.scanWhile(ScanSkipSpace)
		if op == ScanEndArray {
			break
		}
		if op != ScanArrayValue {
			d.error(errPhase)
		}
	}
	return v
}
361102
func (term Range) MarshalJSON() ([]byte, error) {
	if term.IsEmpty() {
		return []byte("null"), nil
	}
	start, err := json.Marshal(term.Start)
	if err != nil {
		return nil, err
	}
	end, err := json.Marshal(term.End)
	if err != nil {
		return nil, err
	}
	return []byte(fmt.Sprintf(`{"start":%s,"end":%s}`, start, end)), nil
}
577503
func (self *Commands) IsArray(value interface{}) error {
	if typeutil.IsArray(value) {
		return nil
	} else {
		return fmt.Errorf("Expected array value")
	}
}
1049168
func InterfaceArrayToStringArray(inArray []interface{}) ([]string, bool) {
	var outArray []string
	allConverted := true
	for _, item := range inArray {
		if istr, ok := item.(string); ok {
			outArray = append(outArray, istr)
		} else {
			allConverted = false
		}
	}
	return outArray, allConverted
}
242166
func (date Date) MarshalJSON() ([]byte, error) {
	if date.IsZero() {
		return []byte("null"), nil
	}
	return []byte(`"` + date.format() + `"`), nil
}
452404
func (enc *Encoder) AddStringKeyOmitEmpty(key, v string) {
	enc.StringKeyOmitEmpty(key, v)
}
810998
func (ia *Int64Array) MarshalJSON() ([]byte, error) {
	if ia == nil || !ia.Valid {
		return []byte("null"), nil
	}
	return json.Marshal(ia.Int64Array)
}