dont attempt to create a std::string from NULL in as_string()

This commit is contained in:
Sean Middleditch 2010-01-13 18:35:07 -08:00
parent 63f762bc48
commit 69437a7183

View File

@ -155,7 +155,10 @@ public:
// get value cast to specified type
const char* as_cstring() const { return json_string_value(_value); }
std::string as_string() const { return as_cstring(); }
std::string as_string() const {
const char* tmp = as_cstring();
return tmp == 0 ? "" : tmp;
}
int as_integer() const { return json_integer_value(_value); }
double as_real() const { return json_real_value(_value); }
double as_number() const { return json_number_value(_value); }