| 133 | } |
| 134 | |
| 135 | func addParamsSlice(m map[string]interface{}, prevkey, newkey string) (map[string]interface{}, error) { |
| 136 | if v, exists := m[prevkey]; exists { |
| 137 | if existSlice, ok := v.([]interface{}); ok { |
| 138 | if len(existSlice) > 0 { |
| 139 | lastItem := existSlice[len(existSlice)-1] |
| 140 | if lastMap, ok := lastItem.(map[string]interface{}); ok { |
| 141 | if _, keyExists := lastMap[newkey]; !keyExists { |
| 142 | return lastMap, nil |
| 143 | } else if reflect.TypeOf(lastMap[newkey]).Kind() == reflect.Slice { |
| 144 | return lastMap, nil |
| 145 | } |
| 146 | } |
| 147 | } |
| 148 | newMap := make(map[string]interface{}) |
| 149 | m[prevkey] = append(existSlice, newMap) |
| 150 | return newMap, nil |
| 151 | } else { |
| 152 | return nil, fmt.Errorf("expected array type under %q, got %T", prevkey, v) |
| 153 | } |
| 154 | } |
| 155 | newMap := make(map[string]interface{}) |
| 156 | m[prevkey] = []interface{}{newMap} |
| 157 | return newMap, nil |
| 158 | } |
| 159 | |
| 160 | func magicFieldValue(v string, opts *ApiOptions) (interface{}, error) { |
| 161 | if strings.HasPrefix(v, "@") { |