getJSON fetches a path and unmarshals JSON into a generic map.
(path string)
| 93 | |
| 94 | // getJSON fetches a path and unmarshals JSON into a generic map. |
| 95 | func (c *Client) getJSON(path string) (map[string]any, error) { |
| 96 | data, err := c.get(path) |
| 97 | if err != nil { |
| 98 | return nil, err |
| 99 | } |
| 100 | var result map[string]any |
| 101 | if err := json.Unmarshal(data, &result); err != nil { |
| 102 | return nil, err |
| 103 | } |
| 104 | return result, nil |
| 105 | } |
| 106 | |
| 107 | // postJSON sends a JSON body via POST and checks for errors. |
| 108 | func (c *Client) postJSON(path string, body any) error { |
no test coverage detected