From 7d95e67308ee0abcce5c7bd66265146d3dfefd74 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 30 Mar 2025 11:35:03 +0300 Subject: useful helper JsonReply moved to the core --- include/m_netlib.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'include') diff --git a/include/m_netlib.h b/include/m_netlib.h index 421ca5b05c..71e2696c4f 100644 --- a/include/m_netlib.h +++ b/include/m_netlib.h @@ -503,6 +503,20 @@ public: } }; +class MIR_APP_EXPORT JsonReply : public MNonCopyable +{ + class JSONNode *m_root = nullptr; + int m_errorCode = 0; + +public: + explicit JsonReply(MHttpResponse *response); + ~JsonReply(); + + __forceinline JSONNode &data() const { return *m_root; } + __forceinline int error() const { return m_errorCode; } + __forceinline operator bool() const { return m_errorCode == 200; } +}; + ///////////////////////////////////////////////////////////////////////////////////////// // Free the memory used by a MHttpRequest structure // -- cgit v1.2.3