as<char*>() now returns true when input is null (issue #330)

This commit is contained in:
Benoit Blanchon
2016-08-15 12:24:08 +02:00
parent a498abc14a
commit 96f486001d
3 changed files with 222 additions and 63 deletions

View File

@@ -300,8 +300,13 @@ class JsonVariant : public JsonVariantBase<JsonVariant> {
return T();
}
// DEPRECATED: use as<char*>() instead
const char *asString() const;
// DEPRECATED: use as<JsonArray>() instead
JsonArray &asArray() const;
// DEPRECATED: use as<JsonObject>() instead
JsonObject &asObject() const;
private:
@@ -324,7 +329,9 @@ class JsonVariant : public JsonVariantBase<JsonVariant> {
return _type == Internals::JSON_OBJECT;
}
bool isString() const {
return _type == Internals::JSON_STRING;
return _type == Internals::JSON_STRING ||
_type == Internals::JSON_UNPARSED && _content.asString &&
!strcmp("null", _content.asString);
}
// The current type of the variant