Description
I am facing problem with comparing two or more json string that will be passed to my function as argument, if anyone can help me with completing the code that will be helpful as I was trying the Value::const_iterator but its showing error.Kinda a newbee in the use of jsoncpp , will appreciate if anyone can help.
the aim is to compare the temp with item1 and item2 and return true or false if both equal.
the code:
bool validate::isEqualItem(std::string item1, std::string item2, std::string temp) {
string i=item1;
string j=item2;
string temp1=temp;
Value root,root1,root2;
Reader reader,reader1,reader2;
bool parsingSuccessful = reader.parse(i, root )&&reader1.parse(j,root1)&&reader2.parse(temp1,root2);
if ( !parsingSuccessful )
{
return false;
}
for(Value::const_iterator order =root2.begin();order!=root2.end();order++){
//showing error in order!=root2.end error is cannot compare structures
}
}
Test cases: isEqualItem({id: 1, name: "test", randomNo: 1}, {id: 1, name: "test", randomNo: 1}, {id: null, name: null, randomNo: null}) //should assert true
isEqualItem({id: 1, name: "test", randomNo: 1}, {id: 1, name: "test", randomNo: 2}, {id: null, name: null, randomNo: null}) //should assert false
isEqualItem({id: 1, name: "test", randomNo: 1}, {id: 1, name: "test", randomNo: 3}, {id: null, name: null}) //should assert true