package gojay

// EncodeEmbeddedJSON encodes an embedded JSON.
// is basically sets the internal buf as the value pointed by v and calls the io.Writer.Write()
func ( *Encoder) ( *EmbeddedJSON) error {
	if .isPooled == 1 {
		panic(InvalidUsagePooledEncoderError("Invalid usage of pooled encoder"))
	}
	.buf = *
	,  := .Write()
	if  != nil {
		return 
	}
	return nil
}

func ( *Encoder) ( *EmbeddedJSON) ([]byte, error) {
	.writeBytes(*)
	return .buf, nil
}

// AddEmbeddedJSON adds an EmbeddedJSON to be encoded.
//
// It basically blindly writes the bytes to the final buffer. Therefore,
// it expects the JSON to be of proper format.
func ( *Encoder) ( *EmbeddedJSON) {
	.grow(len(*) + 4)
	 := .getPreviousRune()
	if  != '[' {
		.writeByte(',')
	}
	.writeBytes(*)
}

// AddEmbeddedJSONOmitEmpty adds an EmbeddedJSON to be encoded or skips it if nil pointer or empty.
//
// It basically blindly writes the bytes to the final buffer. Therefore,
// it expects the JSON to be of proper format.
func ( *Encoder) ( *EmbeddedJSON) {
	if  == nil || len(*) == 0 {
		return
	}
	 := .getPreviousRune()
	if  != '[' {
		.writeByte(',')
	}
	.writeBytes(*)
}

// AddEmbeddedJSONKey adds an EmbeddedJSON and a key to be encoded.
//
// It basically blindly writes the bytes to the final buffer. Therefore,
// it expects the JSON to be of proper format.
func ( *Encoder) ( string,  *EmbeddedJSON) {
	if .hasKeys {
		if !.keyExists() {
			return
		}
	}
	.grow(len() + len(*) + 5)
	 := .getPreviousRune()
	if  != '{' {
		.writeByte(',')
	}
	.writeByte('"')
	.writeStringEscape()
	.writeBytes(objKey)
	.writeBytes(*)
}

// AddEmbeddedJSONKeyOmitEmpty adds an EmbeddedJSON and a key to be encoded or skips it if nil pointer or empty.
//
// It basically blindly writes the bytes to the final buffer. Therefore,
// it expects the JSON to be of proper format.
func ( *Encoder) ( string,  *EmbeddedJSON) {
	if .hasKeys {
		if !.keyExists() {
			return
		}
	}
	if  == nil || len(*) == 0 {
		return
	}
	.grow(len() + len(*) + 5)
	 := .getPreviousRune()
	if  != '{' {
		.writeByte(',')
	}
	.writeByte('"')
	.writeStringEscape()
	.writeBytes(objKey)
	.writeBytes(*)
}