Fixed JSON bool evaluations.

This commit is contained in:
Thulinma 2012-07-20 17:48:40 +02:00
parent 935d5635e5
commit a36ce260ac

View file

@ -286,9 +286,9 @@ JSON::Value::operator std::string(){
/// Automatic conversion to bool. /// Automatic conversion to bool.
/// Returns true if there is anything meaningful stored into this value. /// Returns true if there is anything meaningful stored into this value.
JSON::Value::operator bool(){ JSON::Value::operator bool(){
if (myType == STRING){return strVal == "";} if (myType == STRING){return strVal != "";}
if (myType == INTEGER){return intVal == 0;} if (myType == INTEGER){return intVal != 0;}
if (myType == BOOL){return intVal == 0;} if (myType == BOOL){return intVal != 0;}
if (myType == OBJECT){return size() > 0;} if (myType == OBJECT){return size() > 0;}
if (myType == ARRAY){return size() > 0;} if (myType == ARRAY){return size() > 0;}
if (myType == EMPTY){return false;} if (myType == EMPTY){return false;}