boost::optional<std::string> asString(const JsonObject &json, const std::string &errorBad, Severity severity) { if(json.isString()) { return boost::optional<std::string>(json.asString()); } return boost::none; }
boost::optional<std::string> getString(const JsonObject &json, const std::string &key) { JsonObject value = json[key]; if(value.isNull()) { return boost::none; } else if(value.isString()) { return boost::optional<std::string>(value.asString()); } return boost::none; }
boost::optional<std::string> getString(const JsonObject &json, const std::string &key, const std::string &errorMissing, const std::string &errorBad, Severity severity) { JsonObject value = json[key]; if(value.isNull()) { STADIC_LOG(severity, errorMissing); } else { if(value.isString()) { return boost::optional<std::string>(value.asString()); } else { STADIC_LOG(severity, errorBad); } } return boost::none; }