package jx

import (
	

	
)

// Base64 decodes base64 encoded data from string.
//
// Same as encoding/json, base64.StdEncoding or RFC 4648.
func ( *Decoder) () ([]byte, error) {
	if .Next() == Null {
		if  := .Null();  != nil {
			return nil, errors.Wrap(, "read null")
		}
		return nil, nil
	}
	return .Base64Append([]byte{})
}

// Base64Append appends base64 encoded data from string.
//
// Same as encoding/json, base64.StdEncoding or RFC 4648.
func ( *Decoder) ( []byte) ([]byte, error) {
	if .Next() == Null {
		if  := .Null();  != nil {
			return nil, errors.Wrap(, "read null")
		}
		return , nil
	}
	,  := .StrBytes()
	if  != nil {
		return nil, errors.Wrap(, "bytes")
	}

	 := base64.StdEncoding.DecodedLen(len())
	 := len()
	 = append(, make([]byte, )...)

	,  := base64.StdEncoding.Decode([:], )
	if  != nil {
		return nil, errors.Wrap(, "decode")
	}

	return [:+], nil
}