diff options
author | George Hazan <george.hazan@gmail.com> | 2024-06-09 20:50:11 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2024-06-09 20:50:11 +0300 |
commit | a7d5e440c2116f84d9f189a82a5d989ab4b7a5b7 (patch) | |
tree | 962b55ed641a7bb662a7ed6345fd29010622148b /libs | |
parent | 0f932b4a50a2322bd1e8f69da8633e1f94de6aad (diff) |
fixes #4461 (SkypeWeb: не приходят сообщения)
Diffstat (limited to 'libs')
-rw-r--r-- | libs/libjson/src/stdafx.cxx | 45 |
1 files changed, 17 insertions, 28 deletions
diff --git a/libs/libjson/src/stdafx.cxx b/libs/libjson/src/stdafx.cxx index e96fbffa1b..58c1046959 100644 --- a/libs/libjson/src/stdafx.cxx +++ b/libs/libjson/src/stdafx.cxx @@ -18,33 +18,34 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "stdafx.h"
+static void eraseOldValue(JSONNode &json, const char *pszName)
+{
+ if (pszName && *pszName != 0) {
+ auto n = json.find(pszName);
+ if (n != json.end())
+ json.erase(n);
+ }
+}
+
/////////////////////////////////////////////////////////////////////////////////////////
LIBJSON_DLL(JSONNode&) operator<<(JSONNode &json, const INT_PARAM ¶m)
{
- auto n = json.find(param.szName);
- if (n != json.end())
- json.erase(n);
-
+ eraseOldValue(json, param.szName);
json.push_back(JSONNode(param.szName, param.iValue));
return json;
}
LIBJSON_DLL(JSONNode&) operator<<(JSONNode &json, const INT64_PARAM ¶m)
{
- auto n = json.find(param.szName);
- if (n != json.end())
- json.erase(n);
-
+ eraseOldValue(json, param.szName);
json.push_back(JSONNode(param.szName, param.iValue));
return json;
}
LIBJSON_DLL(JSONNode&) operator<<(JSONNode &json, const SINT64_PARAM ¶m)
{
- auto n = json.find(param.szName);
- if (n != json.end())
- json.erase(n);
+ eraseOldValue(json, param.szName);
char str[40];
_i64toa(param.iValue, str, 10);
@@ -53,19 +54,14 @@ LIBJSON_DLL(JSONNode&) operator<<(JSONNode &json, const SINT64_PARAM ¶m) LIBJSON_DLL(JSONNode&) operator<<(JSONNode &json, const BOOL_PARAM ¶m)
{
- auto n = json.find(param.szName);
- if (n != json.end())
- json.erase(n);
-
+ eraseOldValue(json, param.szName);
json.push_back(JSONNode(param.szName, param.bValue));
return json;
}
LIBJSON_DLL(JSONNode&) operator<<(JSONNode &json, const CHAR_PARAM ¶m)
{
- auto n = json.find(param.szName);
- if (n != json.end())
- json.erase(n);
+ eraseOldValue(json, param.szName);
if (param.szValue == nullptr) {
JSONNode tmp(JSON_NULL); tmp.set_name(param.szName);
@@ -82,19 +78,14 @@ LIBJSON_DLL(JSONNode&) operator<<(JSONNode &json, const CHAR_PARAM ¶m) LIBJSON_DLL(JSONNode&) operator<<(JSONNode &json, const WCHAR_PARAM ¶m)
{
- auto n = json.find(param.szName);
- if (n != json.end())
- json.erase(n);
-
+ eraseOldValue(json, param.szName);
json.push_back(JSONNode(param.szName, ptrA(mir_utf8encodeW(param.wszValue)).get()));
return json;
}
LIBJSON_DLL(JSONNode&) operator<<(JSONNode &json, const NULL_PARAM ¶m)
{
- auto n = json.find(param.szName);
- if (n != json.end())
- json.erase(n);
+ eraseOldValue(json, param.szName);
JSONNode newOne(JSON_NULL);
newOne.set_name(param.szName);
@@ -104,9 +95,7 @@ LIBJSON_DLL(JSONNode&) operator<<(JSONNode &json, const NULL_PARAM ¶m) LIBJSON_DLL(JSONNode&) operator<<(JSONNode &json, const JSON_PARAM ¶m)
{
- auto n = json.find(param.szName);
- if (n != json.end())
- json.erase(n);
+ eraseOldValue(json, param.szName);
JSONNode newOne(param.node);
newOne.set_name(param.szName);
|