| 220 | } |
| 221 | |
| 222 | func findJSONField(v reflect.Value, jsonName string) (reflect.Value, string, bool) { |
| 223 | t := v.Type() |
| 224 | for i := 0; i < t.NumField(); i++ { |
| 225 | field := t.Field(i) |
| 226 | if field.PkgPath != "" { |
| 227 | continue |
| 228 | } |
| 229 | |
| 230 | tag := field.Tag.Get("json") |
| 231 | if tag == "-" { |
| 232 | continue |
| 233 | } |
| 234 | |
| 235 | name := strings.Split(tag, ",")[0] |
| 236 | if name == "" { |
| 237 | continue |
| 238 | } |
| 239 | |
| 240 | if name == jsonName { |
| 241 | return v.Field(i), field.Name, true |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | return reflect.Value{}, "", false |
| 246 | } |
| 247 | |
| 248 | func addForceSendField(v reflect.Value, fieldName string) error { |
| 249 | forceSendFields := v.FieldByName("ForceSendFields") |