MCPcopy Create free account
hub / github.com/chain/txvm / UnmarshalJSON

Method UnmarshalJSON

encoding/json/json.go:42–59  ·  view source on GitHub ↗

UnmarshalJSON satisfies the json.Unmarshaler interface.

(text []byte)

Source from the content-addressed store, hash-verified

40
41// UnmarshalJSON satisfies the json.Unmarshaler interface.
42func (m *Map) UnmarshalJSON(text []byte) error {
43 // UnmarshalJSON takes only valid json, we can take advantage of this
44 // to see if the first character is either '{' for an object or 'n'
45 // for null.
46 v, err := ValueType(text)
47 if err != nil {
48 return err
49 }
50 switch v {
51 case Null:
52 return nil
53 case Object:
54 *m = text
55 return nil
56 default:
57 return ErrNotMap
58 }
59}

Callers 2

mainFunction · 0.95

Calls 1

ValueTypeFunction · 0.85

Tested by 1