| 54 | type nestedJSONSerializer struct{} |
| 55 | |
| 56 | func (nestedJSONSerializer) Serialize(c *Context, i any, indent string) error { |
| 57 | if m, ok := i.(map[string]int); ok && m["outer"] == 1 { |
| 58 | // re-enter c.JSON once before encoding the outer payload |
| 59 | if err := c.JSON(http.StatusOK, map[string]int{"inner": 2}); err != nil { |
| 60 | return err |
| 61 | } |
| 62 | } |
| 63 | return (DefaultJSONSerializer{}).Serialize(c, i, indent) |
| 64 | } |
| 65 | |
| 66 | func (nestedJSONSerializer) Deserialize(c *Context, i any) error { |
| 67 | return (DefaultJSONSerializer{}).Deserialize(c, i) |