MCPcopy Create free account
hub / github.com/PerpetualSoftware/pad / UnmarshalJSON

Method UnmarshalJSON

internal/models/view.go:52–70  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

50// Mirrors ItemCreate.UnmarshalJSON; see flexJSONToString in item.go for
51// the shape contract.
52func (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

Callers

nothing calls this directly

Calls 1

flexJSONToStringFunction · 0.85

Tested by

no test coverage detected