diff --git a/viper.go b/viper.go index 697b7ad..3071df0 100644 --- a/viper.go +++ b/viper.go @@ -559,6 +559,15 @@ func (v *Viper) ReadInConfig() error { return nil } +// ReadInRawConfig reads the given raw bytes to load configuration. It is +// necessary to call SetConfigType(), to let viper know how to parse the given +// configuration. +func ReadInRawConfig(raw []byte) error { return v.ReadInRawConfig(raw) } +func (v *Viper) ReadInRawConfig(raw []byte) error { + v.marshalReader(bytes.NewReader(raw), v.config) + return nil +} + func ReadRemoteConfig() error { return v.ReadRemoteConfig() } func (v *Viper) ReadRemoteConfig() error { err := v.getKeyValueConfig()