MCPcopy
hub / github.com/pocketbase/pocketbase / UnmarshalJSON

Method UnmarshalJSON

core/fields_list.go:318–332  ·  view source on GitHub ↗

UnmarshalJSON implements [json.Unmarshaler] and loads the provided json data into the current FieldsList.

(data []byte)

Source from the content-addressed store, hash-verified

316// UnmarshalJSON implements [json.Unmarshaler] and
317// loads the provided json data into the current FieldsList.
318func (l *FieldsList) UnmarshalJSON(data []byte) error {
319 fwts := []fieldWithType{}
320
321 if err := json.Unmarshal(data, &fwts); err != nil {
322 return err
323 }
324
325 *l = []Field{} // reset
326
327 for _, fwt := range fwts {
328 l.add(-1, fwt.Field)
329 }
330
331 return nil
332}
333
334// MarshalJSON implements the [json.Marshaler] interface.
335func (l FieldsList) MarshalJSON() ([]byte, error) {

Callers 3

TestFieldsListJSONFunction · 0.95
ScanMethod · 0.95
BindCoreFunction · 0.95

Calls 1

addMethod · 0.95

Tested by 1

TestFieldsListJSONFunction · 0.76