// Decode returns the original form of the encoded value, or an error if any occurred.
// Possible return types: float64, bool, string, map[string]interface{}, nil, amf0.ECMAArray, time.Time
// If the contents of b represent a Number (either int or float), it will be returned as a float64
Decode returns the original form of the encoded value, or an error if any occurred.
Possible return types: float64, bool, string, map[string]interface{}, nil, amf0.ECMAArray, time.Time
If the contents of b represent a Number (either int or float), it will be returned as a float64
// Decode returns the original form of the encoded value or an error if any occurred . // Possible return types : float64 bool string map [ string ] interface {} nil amf0 . ECMAArray time . Time // If the contents of b represent a Number ( either int or float ) it will be returned as a float64
func Decode(bytes []byte) (interface{}, error) {
	if bytes[0] == 0x00 && bytes[1] == 0x00 && bytes[2] == TypeObjectEnd {
		return ObjectEnd{}, nil
	}
	switch bytes[0] {
	case TypeNumber:
		return decodeNumber(bytes[1:]), nil
	case TypeBoolean:
		return decodeBoolean(bytes[1]), nil
	case TypeString:
		length := uint32(binary.BigEndian.Uint16(bytes[1:3]))
		return decodeString(bytes[3:], length), nil
	case TypeLongString:
		length := binary.BigEndian.Uint32(bytes[1:5])
		return decodeString(bytes[5:], length), nil
	case TypeObject:
		return decodeObject(bytes[1:]), nil
	case TypeNull:
		return nil, nil
	case TypeECMAArray:
		return decodeECMAArray(bytes[1:]), nil
	case TypeDate:
		return decodeDate(bytes[1:]), nil
	default:
		return nil, errors.New(fmt.Sprintf("cannot decode type with header 0x%v (unsupported type)", hex.EncodeToString(bytes[0:1])))
	}
}
func Decode ( bytes [ ] byte ) ( interface { } , error ) { if bytes [ 0 ] == 0x00 && bytes [ 1 ] == 0x00 && bytes [ 2 ] == TypeObjectEnd { return ObjectEnd { } , nil } switch bytes [ 0 ] { case TypeNumber : return decodeNumber ( bytes [ 1 : ] ) , nil case TypeBoolean : return decodeBoolean ( bytes [ 1 ] ) , nil case TypeString : length := uint32 ( binary . BigEndian . Uint16 ( bytes [ 1 : 3 ] ) ) return decodeString ( bytes [ 3 : ] , length ) , nil case TypeLongString : length := binary . BigEndian . Uint32 ( bytes [ 1 : 5 ] ) return decodeString ( bytes [ 5 : ] , length ) , nil case TypeObject : return decodeObject ( bytes [ 1 : ] ) , nil case TypeNull : return nil , nil case TypeECMAArray : return decodeECMAArray ( bytes [ 1 : ] ) , nil case TypeDate : return decodeDate ( bytes [ 1 : ] ) , nil default : return nil , errors . New ( fmt . Sprintf ( " " , hex . EncodeToString ( bytes [ 0 : 1 ] ) ) ) } }
Decode returns the original form of the encoded value, or an error if any occurred.
Decode returns the original form of the encoded value or an error if any occurred .
// End of object