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

Method MarshalJSON

src/api/node/node.go:96–114  ·  view source on GitHub ↗

MarshalJSON marshals the node to JSON

()

Source from the content-addressed store, hash-verified

94
95// MarshalJSON marshals the node to JSON
96func (n *Node) MarshalJSON() ([]byte, error) {
97 n.mu.RLock()
98 defer n.mu.RUnlock()
99 return json.Marshal(struct {
100 ID string `json:"id"`
101 Name string `json:"name"`
102 IPAddress string `json:"ip_address"`
103 Port int `json:"port"`
104 CreatedAt time.Time `json:"created_at"`
105 UpdatedAt time.Time `json:"updated_at"`
106 }{
107 ID: n.ID,
108 Name: n.Name,
109 IPAddress: n.IPAddress,
110 Port: n.Port,
111 CreatedAt: n.CreatedAt,
112 UpdatedAt: n.UpdatedAt,
113 })
114}
115
116// UnmarshalJSON unmarshals JSON to a node
117func (n *Node) UnmarshalJSON(data []byte) error {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected