pub fn curl_json(url: &str) -> Result<Value, Box<dyn Error + Send + Sync>>Expand description
What: Fetch JSON from a URL using curl and parse into serde_json::Value.
Inputs:
url: HTTP(S) URL to request
Output:
Ok(Value)on success;Errif curl fails or the response is not valid JSON
ยงErrors
- Returns
Errwhen curl command execution fails (I/O error or curl not found) - Returns
Errwhen curl exits with non-zero status (network errors, HTTP errors, timeouts) - Returns
Errwhen response body cannot be decoded as UTF-8 - Returns
Errwhen response body cannot be parsed as JSON
Details:
- Executes curl with appropriate flags and parses the UTF-8 body with
serde_json. - On Windows, uses
-kflag to skip SSL certificate verification. - Provides user-friendly error messages for common curl failure cases.
- For HTTP errors, includes the actual status code in the error message when available.