// jsonToMap allocates a map[string]interface{}, unmarshals a JSON document into it
// and returns it, or error
765717
func jsonToMap(marshaled []byte) (map[string]interface{}, error) {
	tree := make(map[string]interface{})
	d := json.NewDecoder(bytes.NewReader(marshaled))
	d.UseNumber()
	err := d.Decode(&tree)
	if err != nil {
		return nil, fmt.Errorf("error unmarshaling intermediate JSON: %s", err)
	}
	return tree, nil
}
290398
func ToMap(in interface{}, pivot string) interface{} {
	value := reflect.ValueOf(in)

	// input value must be a slice
	if value.Kind() != reflect.Slice {
		panic(fmt.Sprintf("%v must be a slice", in))
	}

	inType := value.Type()

	structType := inType.Elem()

	// retrieve the struct in the slice to deduce key type
	if structType.Kind() == reflect.Ptr {
		structType = structType.Elem()
	}

	field, _ := structType.FieldByName(pivot)

	// value of the map will be the input type
	collectionType := reflect.MapOf(field.Type, inType.Elem())

	// create a map from scratch
	collection := reflect.MakeMap(collectionType)

	for i := 0; i < value.Len(); i++ {
		instance := value.Index(i)
		var field reflect.Value

		if instance.Kind() == reflect.Ptr {
			field = instance.Elem().FieldByName(pivot)
		} else {
			field = instance.FieldByName(pivot)
		}

		collection.SetMapIndex(field, instance)
	}

	return collection.Interface()
}
252976
func (c *SyncCollector) ToMap() map[string]interface{} {
	var co Collector
	c.rw.RLock()
	co = c.c.Clone()
	c.rw.RUnlock()
	return co
}
559213
func headerToMap(h textproto.Header) stdtextproto.MIMEHeader {
	m := make(stdtextproto.MIMEHeader)
	fields := h.Fields()
	for fields.Next() {
		m.Add(fields.Key(), fields.Value())
	}
	return m
}
509238
func (mmap MarshalMap) StringMap(key string) (map[string]string, error) {
	val, exists := mmap.Value(key)
	if !exists {
		return nil, fmt.Errorf(`"%s" is not set`, key)
	}

	switch val.(type) {
	case map[string]string:
		return val.(map[string]string), nil

	default:
		valueMeta := reflect.ValueOf(val)
		if valueMeta.Kind() != reflect.Map {
			return nil, fmt.Errorf(`"%s" is expected to be a map[string]string but is %T`, key, val)
		}

		result := make(map[string]string)
		for _, keyMeta := range valueMeta.MapKeys() {
			strKey, isString := keyMeta.Interface().(string)
			if !isString {
				return nil, fmt.Errorf(`"%s" is expected to be a map[string]string. Key is not a string`, key)
			}

			value := valueMeta.MapIndex(keyMeta)
			strValue, isString := value.Interface().(string)
			if !isString {
				return nil, fmt.Errorf(`"%s" is expected to be a map[string]string. Value is not a string`, key)
			}

			result[strKey] = strValue
		}

		return result, nil
	}
}
509218
func tagsToMap(ts []*ec2.Tag) map[string]string {
	result := make(map[string]string)
	for _, t := range ts {
		if !tagIgnored(t) {
			result[*t.Key] = *t.Value
		}
	}

	return result
}
1167826
func tagsToMapDS(ts []*directoryservice.Tag) map[string]string {
	result := make(map[string]string)
	for _, t := range ts {
		if !tagIgnoredDS(t) {
			result[*t.Key] = *t.Value
		}
	}

	return result
}
371301
func driverArgsToMap(args []driver.Value) (map[string]interface{}, error) {
	output := map[string]interface{}{}
	for _, arg := range args {
		argBytes, ok := arg.([]byte)
		if !ok {
			return nil, errors.New("You must pass only a gob encoded map to the Exec/Query args")
		}

		m, err := encoding.Unmarshal(argBytes)
		if err != nil {
			return nil, err
		}

		for k, v := range m.(map[string]interface{}) {
			output[k] = v
		}

	}

	return output, nil
}
991843
func (mmap MarshalMap) MarshalMap(key string) (MarshalMap, error) {
	val, exists := mmap.Value(key)
	if !exists {
		return nil, fmt.Errorf(`"%s" is not set`, key)
	}

	return ConvertToMarshalMap(val, nil)
}
748483
func pathToMap(path string, data map[string]interface{}) map[string]interface{} {
	if path == "." {
		return data
	}
	ap := strings.Split(path, ".")
	if len(ap) == 0 {
		return nil
	}
	n := []map[string]interface{}{}
	// created nested map for each key, adding to slice
	for _, v := range ap {
		nm := make(map[string]interface{})
		nm[v] = make(map[string]interface{})
		n = append(n, nm)
	}
	// find the last key (map) and set our data
	for i, d := range n {
		for k := range d {
			z := i + 1
			if z == len(n) {
				n[i][k] = data
				break
			}
			n[i][k] = n[z]
		}
	}

	return n[0]
}
1165785
func toMap(object interface{}) (map[string]interface{}, error) {
	if m, ok := object.(map[string]interface{}); ok {
		return m, nil
	}
	data, err := json.Marshal(object)
	if err != nil {
		return nil, driver.WithStack(err)
	}
	var m map[string]interface{}
	if err := json.Unmarshal(data, &m); err != nil {
		return nil, driver.WithStack(err)
	}
	return m, nil
}
965365
func funcMap(appPkg string, actionImpls map[string]string) template.FuncMap {
	return template.FuncMap{
		"tempvar":   tempvar,
		"okResp":    okResp,
		"targetPkg": func() string { return appPkg },
		"actionBody": func(name string) string {
			body, ok := actionImpls[name]
			if !ok {
				return defaultActionBody
			}
			return body
		},
		"printResp": func(name string) bool {
			_, ok := actionImpls[name]
			return !ok
		},
	}
}
1208891
func (g *Generator) funcMap() template.FuncMap {
	return template.FuncMap{
		"EscapeMD":       escapeMD,
		"Symbol":         g.symbol,
		"LinkifySymbols": g.linkifySymbols,
	}
}
763201
func (l Labels) ToMap() map[ACIdentifier]string {
	labelsMap := make(map[ACIdentifier]string)
	for _, lbl := range l {
		labelsMap[lbl.Name] = lbl.Value
	}
	return labelsMap
}
647567
func (j *Json) Map() (map[string]interface{}, error) {
	if m, ok := (j.data).(map[string]interface{}); ok {
		return m, nil
	}
	return nil, errors.New("type assertion to map[string]interface{} failed")
}
630149
func toInfMap(sMap map[string]interface{}) map[interface{}]interface{} {
	newMap := make(map[interface{}]interface{})
	for k, v := range sMap {
		var newValue interface{}
		switch v := v.(type) {
		case map[string]interface{}:
			newValue = toInfMap(v)
		default:
			newValue = v
		}
		newMap[k] = newValue
	}
	return newMap
}
883026
func tagsToMapGeneric(ts map[string]*string) map[string]string {
	result := make(map[string]string)
	for k, v := range ts {
		if !tagIgnoredGeneric(k) {
			result[k] = aws.StringValue(v)
		}
	}

	return result
}