Parse JSON from response body with error handling
| 150 | |
| 151 | /// Parse JSON from response body with error handling |
| 152 | fl::json parse_json_body() const { |
| 153 | fl::json parsed = fl::json::parse(mBody); |
| 154 | if (parsed.is_null() && (!mBody.empty())) { |
| 155 | // If parsing failed but we have content, return null JSON |
| 156 | // This allows safe chaining: resp.json()["key"] | default |
| 157 | return fl::json(nullptr); |
| 158 | } |
| 159 | return parsed; |
| 160 | } |
| 161 | |
| 162 | static fl::string get_default_status_text(int status) { // okay static in header |
| 163 | switch (status) { |