From 654aba9d146fa931628790e2b16c5ca0f28907b3 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 3 Jan 2018 22:43:15 +0300 Subject: libjson: - fix for printing null fields; - fix for passing NULL_PARAM & JSON_PARAM --- libs/libjson/src/JSONWriter.cpp | 3 ++- libs/libjson/src/internalJSONNode.cpp | 3 +++ libs/libjson/src/stdafx.cxx | 8 ++++++-- 3 files changed, 11 insertions(+), 3 deletions(-) (limited to 'libs/libjson') diff --git a/libs/libjson/src/JSONWriter.cpp b/libs/libjson/src/JSONWriter.cpp index d5f7e5d380..ce753970c8 100644 --- a/libs/libjson/src/JSONWriter.cpp +++ b/libs/libjson/src/JSONWriter.cpp @@ -158,8 +158,9 @@ json_string internalJSONNode::Write(unsigned int indent, bool arrayChild){ case JSON_ARRAY: //write out the child nodes int he array Fetch(); return WriteComment(indent) + WriteName(formatted, arrayChild) + JSON_TEXT("[") + WriteChildren(indent) + JSON_TEXT("]"); - case JSON_NUMBER: //write out a literal, without quotes case JSON_NULL: + return WriteComment(indent) + WriteName(formatted, arrayChild) + CONST_NULL; + case JSON_NUMBER: //write out a literal, without quotes case JSON_BOOL: return WriteComment(indent) + WriteName(formatted, arrayChild) + _string; } diff --git a/libs/libjson/src/internalJSONNode.cpp b/libs/libjson/src/internalJSONNode.cpp index 7cee25f27a..1b51582db2 100644 --- a/libs/libjson/src/internalJSONNode.cpp +++ b/libs/libjson/src/internalJSONNode.cpp @@ -36,6 +36,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. lots of copies, but since strings are copy on write, this assignment is much faster */ + +const json_string CONST_NULL(JSON_TEXT("null")); + static const json_string CONST_TRUE(JSON_TEXT("true")); static const json_string CONST_FALSE(JSON_TEXT("false")); diff --git a/libs/libjson/src/stdafx.cxx b/libs/libjson/src/stdafx.cxx index 98f83a0b3a..32eb3c894f 100644 --- a/libs/libjson/src/stdafx.cxx +++ b/libs/libjson/src/stdafx.cxx @@ -54,12 +54,16 @@ LIBJSON_DLL(JSONNode&) operator<<(JSONNode &json, const WCHAR_PARAM ¶m) LIBJSON_DLL(JSONNode&) operator<<(JSONNode &json, const NULL_PARAM ¶m) { - json.push_back(JSONNode(param.szName, nullptr)); + JSONNode newOne(JSON_NULL); + newOne.set_name(param.szName); + json.push_back(newOne); return json; } LIBJSON_DLL(JSONNode&) operator<<(JSONNode &json, const JSON_PARAM ¶m) { - json.push_back(JSONNode(param.szName, param.node)); + JSONNode newOne(param.node); + newOne.set_name(param.szName); + json.push_back(newOne); return json; } -- cgit v1.2.3