MCPcopy Create free account
hub / github.com/KOSASIH/skybridge / UnmarshalJSON

Method UnmarshalJSON

src/api/node/node.go:117–138  ·  view source on GitHub ↗

UnmarshalJSON unmarshals JSON to a node

(data []byte)

Source from the content-addressed store, hash-verified

115
116// UnmarshalJSON unmarshals JSON to a node
117func (n *Node) UnmarshalJSON(data []byte) error {
118 var node struct {
119 ID string `json:"id"`
120 Name string `json:"name"`
121 IPAddress string `json:"ip_address"`
122 Port int `json:"port"`
123 CreatedAt time.Time `json:"created_at"`
124 UpdatedAt time.Time `json:"updated_at"`
125 }
126 if err := json.Unmarshal(data, &node); err != nil {
127 return err
128 }
129 n.mu.Lock()
130 defer n.mu.Unlock()
131 n.ID = node.ID
132 n.Name = node.Name
133 n.IPAddress = node.IPAddress
134 n.Port = node.Port
135 n.CreatedAt = node.CreatedAt
136 n.UpdatedAt = node.UpdatedAt
137 return nil
138}
139
140// NodeService represents a node service
141type NodeService interface {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected