detect JSON for escaped strings
* fix compilation error
fix compilation error
* free data when not filtered
free data when not filtered
* added filter description
added filter description
* detect JSON for escaped strings
detect JSON for escaped strings
@@ -417,19 +417,26 @@ ConfigCategory::CategoryItem::CategoryItem(const string& name, const Value& item
throw new ConfigMalformed();
}
if (item.HasMember("type"))
+ {
m_type = item["type"].GetString();
+ }
else
+ {
m_type = "";
+ }
+
if (item.HasMember("description"))
+ {
m_description = item["description"].GetString();
+ }
else
- m_description = "";
- if (item.HasMember("value") && item["value"].IsString())
{
- m_value = item["value"].GetString();
- m_itemType = StringItem;
+ m_description = "";
}
- else if (item.HasMember("value") && item["value"].IsObject())
+
+ // Item "value" can be an escaped JSON string, so check m_type JSON as well
+ if (item.HasMember("value") &&
+ ((item["value"].IsObject() || m_type.compare("JSON") == 0)))
{
rapidjson::StringBuffer strbuf;
rapidjson::Writer<rapidjson::StringBuffer> writer(strbuf);
@@ -437,16 +444,19 @@ ConfigCategory::CategoryItem::CategoryItem(const string& name, const Value& item
m_value = strbuf.GetString();
m_itemType = JsonItem;
}
- else
+ else if (item.HasMember("value") && item["value"].IsString())
{
- m_value = "";
+ m_value = item["value"].GetString();
+ m_itemType = StringItem;
}
- if (item.HasMember("default") && item["default"].IsString())
+ else
{
- m_default = item["default"].GetString();
- m_itemType = StringItem;
+ m_value = "";
}
- else if (item.HasMember("default") && item["default"].IsObject())
+
+ // Item "default" can be an escaped JSON string, so check m_type JSON as well
+ if (item.HasMember("default") &&
+ ((item["default"].IsObject() || m_type.compare("JSON") == 0)))
{
rapidjson::StringBuffer strbuf;
rapidjson::Writer<rapidjson::StringBuffer> writer(strbuf);
@@ -454,9 +464,16 @@ ConfigCategory::CategoryItem::CategoryItem(const string& name, const Value& item
m_default = strbuf.GetString();
m_itemType = JsonItem;
}
+ else if (item.HasMember("default") && item["default"].IsString())
+ {
+ m_default = item["default"].GetString();
+ m_itemType = StringItem;
+ }
else
+ {
m_default = "";
}
+}
/**
* Constructor for a configuration item
