MCPcopy
hub / github.com/cortexlabs/cortex / InterfaceToStrInterfaceMap

Function InterfaceToStrInterfaceMap

pkg/lib/cast/interface.go:671–695  ·  view source on GitHub ↗
(in interface{})

Source from the content-addressed store, hash-verified

669}
670
671func InterfaceToStrInterfaceMap(in interface{}) (map[string]interface{}, bool) {
672 if in == nil {
673 return nil, true
674 }
675
676 if strMap, ok := in.(map[string]interface{}); ok {
677 return strMap, true
678 }
679
680 inMap, ok := InterfaceToInterfaceInterfaceMap(in)
681 if !ok {
682 return nil, false
683 }
684
685 out := map[string]interface{}{}
686
687 for key, value := range inMap {
688 casted, ok := key.(string)
689 if !ok {
690 return nil, false
691 }
692 out[casted] = value
693 }
694 return out, true
695}
696
697// Recursively casts interface->interface maps to string->interface maps
698func JSONMarshallable(in interface{}) (interface{}, bool) {

Callers 8

FlattenAllStrValuesFunction · 0.92
InterfaceMapFunction · 0.92
StructFunction · 0.92
InterfaceStructFunction · 0.92
ReadYAMLFileStrMapFunction · 0.92
MustReadYAMLStrMapFunction · 0.92
InterfaceMapListFunction · 0.92

Calls 1

Tested by

no test coverage detected