MarshalJSON marshals the node to JSON
()
| 94 | |
| 95 | // MarshalJSON marshals the node to JSON |
| 96 | func (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 |
| 117 | func (n *Node) UnmarshalJSON(data []byte) error { |
nothing calls this directly
no outgoing calls
no test coverage detected