ParseJSONResponse decodes a raw SDK response body as JSON. CallAPI and HandleResponse both delegate to this function.
(resp *larkcore.ApiResp)
| 194 | // ParseJSONResponse decodes a raw SDK response body as JSON. |
| 195 | // CallAPI and HandleResponse both delegate to this function. |
| 196 | func ParseJSONResponse(resp *larkcore.ApiResp) (interface{}, error) { |
| 197 | var result interface{} |
| 198 | dec := json.NewDecoder(bytes.NewReader(resp.RawBody)) |
| 199 | dec.UseNumber() |
| 200 | if err := dec.Decode(&result); err != nil { |
| 201 | return nil, fmt.Errorf("response parse error: %w (body: %s)", err, util.TruncateStr(string(resp.RawBody), 500)) |
| 202 | } |
| 203 | return result, nil |
| 204 | } |
| 205 | |
| 206 | // ── File saving ── |
| 207 |