Fixes to JSON library.
This commit is contained in:
parent
67dc1848e7
commit
1eb5725751
1 changed files with 10 additions and 12 deletions
20
lib/json.cpp
20
lib/json.cpp
|
@ -427,7 +427,9 @@ JSON::Value::Value(bool val) {
|
||||||
|
|
||||||
/// Compares a JSON::Value to another for equality.
|
/// Compares a JSON::Value to another for equality.
|
||||||
bool JSON::Value::operator==(const JSON::Value & rhs) const {
|
bool JSON::Value::operator==(const JSON::Value & rhs) const {
|
||||||
if (myType != rhs.myType) return false;
|
if (myType != rhs.myType){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (myType == INTEGER || myType == BOOL) {
|
if (myType == INTEGER || myType == BOOL) {
|
||||||
return intVal == rhs.intVal;
|
return intVal == rhs.intVal;
|
||||||
}
|
}
|
||||||
|
@ -437,26 +439,22 @@ bool JSON::Value::operator==(const JSON::Value & rhs) const {
|
||||||
if (myType == EMPTY) {
|
if (myType == EMPTY) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (myType == OBJECT) {
|
if (size() != rhs.size()){
|
||||||
if (objVal.size() != rhs.objVal.size()) return false;
|
|
||||||
for (std::map<std::string, Value*>::const_iterator it = objVal.begin(); it != objVal.end(); ++it) {
|
|
||||||
if (!rhs.isMember(it->first)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (*(it->second) != rhs.objVal.find(it->first)->second) {
|
if (myType == OBJECT) {
|
||||||
|
jsonForEachConst(*this, it){
|
||||||
|
if (!rhs.isMember(it.key()) || *it != rhs[it.key()]) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (myType == ARRAY) {
|
if (myType == ARRAY) {
|
||||||
if (arrVal.size() != rhs.arrVal.size()) return false;
|
jsonForEachConst(*this, it){
|
||||||
int i = 0;
|
if (*it != rhs[it.num()]) {
|
||||||
for (std::deque<Value*>::const_iterator it = arrVal.begin(); it != arrVal.end(); ++it) {
|
|
||||||
if (**it != *(rhs.arrVal[i])) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue