| 647 | // ========== Response Class Method Implementations ========== |
| 648 | |
| 649 | fl::json Response::json() const { |
| 650 | if (!mJsonParsed) { |
| 651 | if (is_json() || mBody.find("{") != fl::string::npos || mBody.find("[") != fl::string::npos) { |
| 652 | mCachedJson = parse_json_body(); |
| 653 | } else { |
| 654 | FL_WARN("Response is not JSON: " << mBody); |
| 655 | mCachedJson = fl::json(nullptr); // Not JSON content |
| 656 | } |
| 657 | mJsonParsed = true; |
| 658 | } |
| 659 | |
| 660 | return mCachedJson.has_value() ? *mCachedJson : fl::json(nullptr); |
| 661 | } |
| 662 | |
| 663 | } // namespace http |
| 664 | } // namespace net |