Recursively casts interface->interface maps to string->interface maps
(in interface{})
| 696 | |
| 697 | // Recursively casts interface->interface maps to string->interface maps |
| 698 | func JSONMarshallable(in interface{}) (interface{}, bool) { |
| 699 | if in == nil { |
| 700 | return nil, true |
| 701 | } |
| 702 | |
| 703 | if inMap, ok := InterfaceToInterfaceInterfaceMap(in); ok { |
| 704 | out := map[string]interface{}{} |
| 705 | for key, value := range inMap { |
| 706 | castedKey, ok := key.(string) |
| 707 | if !ok { |
| 708 | return nil, false |
| 709 | } |
| 710 | castedValue, ok := JSONMarshallable(value) |
| 711 | if !ok { |
| 712 | return nil, false |
| 713 | } |
| 714 | out[castedKey] = castedValue |
| 715 | } |
| 716 | return out, true |
| 717 | } else if inSlice, ok := InterfaceToInterfaceSlice(in); ok { |
| 718 | out := make([]interface{}, 0, len(inSlice)) |
| 719 | for _, inValue := range inSlice { |
| 720 | castedInValue, ok := JSONMarshallable(inValue) |
| 721 | if !ok { |
| 722 | return nil, false |
| 723 | } |
| 724 | out = append(out, castedInValue) |
| 725 | } |
| 726 | return out, true |
| 727 | } |
| 728 | return in, true |
| 729 | } |
| 730 | |
| 731 | func InterfaceToStrStrMap(in interface{}) (map[string]string, bool) { |
| 732 | if in == nil { |