UnmarshalJSON for CollectionCreate accepts `settings` either as the canonical JSON-encoded string shape (matches models.Collection.Settings storage) OR as the natural nested object shape any reasonable HTTP client would send. Mirrors ItemCreate.UnmarshalJSON; see flexJSONToString in item.go for the
(data []byte)
| 110 | // client would send. Mirrors ItemCreate.UnmarshalJSON; see |
| 111 | // flexJSONToString in item.go for the shape contract. |
| 112 | func (c *CollectionCreate) UnmarshalJSON(data []byte) error { |
| 113 | type alias CollectionCreate |
| 114 | aux := struct { |
| 115 | Settings json.RawMessage `json:"settings,omitempty"` |
| 116 | *alias |
| 117 | }{alias: (*alias)(c)} |
| 118 | |
| 119 | if err := json.Unmarshal(data, &aux); err != nil { |
| 120 | return err |
| 121 | } |
| 122 | |
| 123 | if settingsStr, err := flexJSONToString(aux.Settings, '{', ErrInvalidSettingsType); err != nil { |
| 124 | return err |
| 125 | } else if settingsStr != nil { |
| 126 | c.Settings = *settingsStr |
| 127 | } |
| 128 | |
| 129 | return nil |
| 130 | } |
| 131 | |
| 132 | // UnmarshalJSON for CollectionUpdate accepts `settings` either as the |
| 133 | // canonical JSON-encoded string shape OR as the natural nested object |
nothing calls this directly
no test coverage detected