(rv reflect.Value)
| 120 | } |
| 121 | |
| 122 | func encodeStruct(rv reflect.Value) ([]byte, bool) { |
| 123 | if rv.Kind() == reflect.Struct { |
| 124 | for i := 0; i < rv.NumField(); i++ { |
| 125 | ft := rv.Type().Field(i) |
| 126 | // Found a field with a json tag. |
| 127 | if ft.Tag.Get("json") != "" { |
| 128 | return encodeJSON(rv.Interface()), true |
| 129 | } |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | return nil, false |
| 134 | } |
| 135 | |
| 136 | func encodeJSON(v interface{}) []byte { |
| 137 | b, err := json.Marshal(v) |