Exemplo n.º 1
0
boost::optional<bool> asBool(const JsonObject &json, const std::string &errorBad, Severity severity)
{
    if (json.isBool()) {
        return boost::optional<bool>(json.asBool());
    }
    return boost::none;
}
Exemplo n.º 2
0
boost::optional<bool> getBool(const JsonObject &json, const std::string &key, bool defaultValue,
                              const std::string &errorBad, Severity severity)
{
    JsonObject value = json[key];
    if(value.isNull()) {
        return boost::optional<bool>(defaultValue);
    } else {
        if(value.isBool()) {
            return boost::optional<bool>(value.asBool());
        } else {
            STADIC_LOG(severity, errorBad);
        }
    }
    return boost::none;
}