Generating a JSON representation from a blank object is an error
condition, so we were crashing. The unit tests validated this
situation, so this fix returns the correct value in that situation.
Additionally corrected a comment highlighted in a previous review.
Change-Id: I113bf0ad53bb939d90278928257ff7b56aa4959b
Signed-off-by: Erich Keane <erich.keane@intel.com>
#include <OicJsonSerializer.hpp>
#include <algorithm>
-// code needed to serialize a string::Attribute value map
+// code needed to serialize a string=>Attribute value map
namespace OC
{
namespace detail
std::string MessageContainer::getJSONRepresentation(OCInfoFormat f) const
{
+ if(empty())
+ {
+ return "{}";
+ }
+
std::stringstream os;
// note: the block is required because cereal closes the JSON string
return false;
}
+ if(m_children.size() > 0)
+ {
+ return false;
+ }
+
return true;
}