summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2024-05-28 21:09:00 +0300
committerGeorge Hazan <george.hazan@gmail.com>2024-05-28 21:09:00 +0300
commit1fc27d239cb945899246a423b0fba9d28277d3ab (patch)
tree2584494f49c8b536764becd4ccbdb7953092b44b /libs
parent82f2d8a1c1e3b49cf0dc05d1456eac97df639262 (diff)
libjson: new data to replace existing one
Diffstat (limited to 'libs')
-rw-r--r--libs/libjson/src/stdafx.cxx32
1 files changed, 32 insertions, 0 deletions
diff --git a/libs/libjson/src/stdafx.cxx b/libs/libjson/src/stdafx.cxx
index 178e138057..e96fbffa1b 100644
--- a/libs/libjson/src/stdafx.cxx
+++ b/libs/libjson/src/stdafx.cxx
@@ -22,18 +22,30 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
LIBJSON_DLL(JSONNode&) operator<<(JSONNode &json, const INT_PARAM &param)
{
+ auto n = json.find(param.szName);
+ if (n != json.end())
+ json.erase(n);
+
json.push_back(JSONNode(param.szName, param.iValue));
return json;
}
LIBJSON_DLL(JSONNode&) operator<<(JSONNode &json, const INT64_PARAM &param)
{
+ auto n = json.find(param.szName);
+ if (n != json.end())
+ json.erase(n);
+
json.push_back(JSONNode(param.szName, param.iValue));
return json;
}
LIBJSON_DLL(JSONNode&) operator<<(JSONNode &json, const SINT64_PARAM &param)
{
+ auto n = json.find(param.szName);
+ if (n != json.end())
+ json.erase(n);
+
char str[40];
_i64toa(param.iValue, str, 10);
return json << CHAR_PARAM(param.szName, str);
@@ -41,12 +53,20 @@ LIBJSON_DLL(JSONNode&) operator<<(JSONNode &json, const SINT64_PARAM &param)
LIBJSON_DLL(JSONNode&) operator<<(JSONNode &json, const BOOL_PARAM &param)
{
+ auto n = json.find(param.szName);
+ if (n != json.end())
+ json.erase(n);
+
json.push_back(JSONNode(param.szName, param.bValue));
return json;
}
LIBJSON_DLL(JSONNode&) operator<<(JSONNode &json, const CHAR_PARAM &param)
{
+ auto n = json.find(param.szName);
+ if (n != json.end())
+ json.erase(n);
+
if (param.szValue == nullptr) {
JSONNode tmp(JSON_NULL); tmp.set_name(param.szName);
json.push_back(tmp);
@@ -62,12 +82,20 @@ LIBJSON_DLL(JSONNode&) operator<<(JSONNode &json, const CHAR_PARAM &param)
LIBJSON_DLL(JSONNode&) operator<<(JSONNode &json, const WCHAR_PARAM &param)
{
+ auto n = json.find(param.szName);
+ if (n != json.end())
+ json.erase(n);
+
json.push_back(JSONNode(param.szName, ptrA(mir_utf8encodeW(param.wszValue)).get()));
return json;
}
LIBJSON_DLL(JSONNode&) operator<<(JSONNode &json, const NULL_PARAM &param)
{
+ auto n = json.find(param.szName);
+ if (n != json.end())
+ json.erase(n);
+
JSONNode newOne(JSON_NULL);
newOne.set_name(param.szName);
json.push_back(newOne);
@@ -76,6 +104,10 @@ LIBJSON_DLL(JSONNode&) operator<<(JSONNode &json, const NULL_PARAM &param)
LIBJSON_DLL(JSONNode&) operator<<(JSONNode &json, const JSON_PARAM &param)
{
+ auto n = json.find(param.szName);
+ if (n != json.end())
+ json.erase(n);
+
JSONNode newOne(param.node);
newOne.set_name(param.szName);
json.push_back(newOne);