UnmarshalJSON for ViewCreate accepts `config` either as the canonical JSON-encoded string shape (matches models.View.Config storage) OR as the natural nested object shape any reasonable HTTP client would send. Mirrors ItemCreate.UnmarshalJSON; see flexJSONToString in item.go for the shape contract.
(data []byte)
| 50 | // Mirrors ItemCreate.UnmarshalJSON; see flexJSONToString in item.go for |
| 51 | // the shape contract. |
| 52 | func (c *ViewCreate) UnmarshalJSON(data []byte) error { |
| 53 | type alias ViewCreate |
| 54 | aux := struct { |
| 55 | Config json.RawMessage `json:"config,omitempty"` |
| 56 | *alias |
| 57 | }{alias: (*alias)(c)} |
| 58 | |
| 59 | if err := json.Unmarshal(data, &aux); err != nil { |
| 60 | return err |
| 61 | } |
| 62 | |
| 63 | if configStr, err := flexJSONToString(aux.Config, '{', ErrInvalidConfigType); err != nil { |
| 64 | return err |
| 65 | } else if configStr != nil { |
| 66 | c.Config = *configStr |
| 67 | } |
| 68 | |
| 69 | return nil |
| 70 | } |
| 71 | |
| 72 | // UnmarshalJSON for ViewUpdate accepts `config` either as the canonical |
| 73 | // JSON-encoded string shape OR as the natural nested object shape any |
nothing calls this directly
no test coverage detected