Esempio n. 1
0
func (l *Loader) loadMapIntoValues(key config.Key, values *config.Values, object map[string]interface{}) {
	for keyPart, v := range object {
		if l.KeyPartTransform != nil {
			keyPart = l.KeyPartTransform(keyPart)
		}
		nextKey := key.AppendStrings(keyPart)
		if m, ok := v.(map[string]interface{}); ok {
			l.loadMapIntoValues(nextKey, values, m)
		} else {
			l.loadSingleIntoValues(nextKey, values, v)
		}
	}
}
Esempio n. 2
0
func (l *Loader) loadSingleIntoValues(key config.Key, values *config.Values, value interface{}) {
	if !key.StartsWith(l.KeyPrefix) || !key.EndsWith(l.KeySuffix) {
		return
	}
	if value == nil {
		if l.DiscardNull {
			return
		}
		values.Put(key, nil)
	}
	switch v := value.(type) {
	case jsonlib.Number:
		l.loadNumberIntoValues(key, values, v)
	default:
		values.Put(key, v)
	}
}