GH #144: Poco::Dynamic emits invalid JSON

GH #144: Poco::Dynamic emits invalid JSON
This commit is contained in:
Aleksandar Fabijanic
2013-04-06 11:04:33 -05:00
parent d0ff7ccf7c
commit f9aea9acdf
7 changed files with 74 additions and 22 deletions

View File

@@ -499,7 +499,7 @@ void Var::skipWhiteSpace(const std::string& val, std::string::size_type& pos)
std::string Var::toString(const Var& any)
{
std::string res;
appendJSONString(res, any);
appendJSONValue(res, any);
return res;
}

View File

@@ -56,12 +56,28 @@ bool isJSONString(const Var& any)
{
return any.type() == typeid(std::string) ||
any.type() == typeid(char) ||
any.type() == typeid(char*) ||
any.type() == typeid(Poco::DateTime) ||
any.type() == typeid(Poco::LocalDateTime);
any.type() == typeid(Poco::LocalDateTime) ||
any.type() == typeid(Poco::Timestamp);
}
void appendJSONString(std::string& val, const Var& any)
{
val.append(1, '"');
val.append(any.convert<std::string>());
val.append(1, '"');
}
void appendJSONKey(std::string& val, const Var& any)
{
return appendJSONString(val, any);
}
void appendJSONValue(std::string& val, const Var& any)
{
if (any.isEmpty()) val.append("null");
else