// Setting the third parameter, omitempty, to true causes empty values to be ignored.
// Setting the fourth parameter, rawValues, to false causes each value to be wrapped in double quotes
// to make it a valid string.
Setting the third parameter, omitempty, to true causes empty values to be ignored.
Setting the fourth parameter, rawValues, to false causes each value to be wrapped in double quotes
to make it a valid string.
// Setting the third parameter omitempty to true causes empty values to be ignored . // Setting the fourth parameter rawValues to false causes each value to be wrapped in double quotes // to make it a valid string .
func (b *ObjectBuilder) AddArray(key string, items []string, omitEmpty bool, rawValues bool) (int, error) {
	bytesWritten, _ := b.writeStrings(b.prefixForNewItems(), QuoteWrap(key), ":[")
	for i, item := range items {
		if item == "" {
			if !omitEmpty {
				item = `""`
			} else {
				continue
			}
		} else if !rawValues {
			item = QuoteWrap(item)
		}
		if i != 0 {
			m, _ := b.WriteString(",")
			bytesWritten += m
		}
		m, _ := b.WriteString(item)
		bytesWritten += m
	}
	m, _ := b.WriteString("]")
	return bytesWritten + m, nil
}
func ( b * ObjectBuilder ) AddArray ( key string , items [ ] string , omitEmpty bool , rawValues bool ) ( int , error ) { bytesWritten , _ := b . writeStrings ( b . prefixForNewItems ( ) , QuoteWrap ( key ) , " " ) for i , item := range items { if item == " " { if ! omitEmpty { item = `""` } else { continue } } else if ! rawValues { item = QuoteWrap ( item ) } if i != 0 { m , _ := b . WriteString ( " " ) bytesWritten += m } m , _ := b . WriteString ( item ) bytesWritten += m } m , _ := b . WriteString ( " " ) return bytesWritten + m , nil }
Setting the third parameter, omitempty, to true causes empty values to be ignored.
Setting the third parameter omitempty to true causes empty values to be ignored .