mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-24 17:30:44 +02:00
GH #144: Poco::Dynamic emits invalid JSON
GH #144: Poco::Dynamic emits invalid JSON
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user