summaryrefslogtreecommitdiff
path: root/libs/libjson/src
diff options
context:
space:
mode:
Diffstat (limited to 'libs/libjson/src')
-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);