-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Equality operator fails #931
Comments
I would expect two arrays having different orders to result in the JSON being different. Objects have unordered keys, but arrays are ordered. Why would you expect them to be the same? |
|
These two would be the same, for example:
|
OK, fair enough. I missed the part about the ordered list. Thanks for the clarification. |
Bug Report
What is the issue you have?
The equality operator returns false even though 2 JSON objects have the same content, just different order.
Please describe the steps to reproduce the issue. Can you provide a small but working code example?
#include < iostream >
#include "json.hpp"
int main(int argc, char** argv)
{
auto j1 = R"#(
{
"alertResponses": [
{"profileId": "CEMAV1",
"errors": [{"code": 1666, "title": "Not Allowed"}]
},
{"profileId": "CEMAV2",
"errors": [{"code": 1666, "title": "Not Allowed"}]
}]
}
)#"_json;
auto j2 = R"#(
{
"alertResponses": [
{"profileId": "CEMAV2",
"errors": [{"code": 1666, "title": "Not Allowed"}]
},
{"profileId": "CEMAV1",
"errors": [{"code": 1666, "title": "Not Allowed"}]
}]
}
)#"_json;
if (j1 == j2) std::cout << "The same!" << std::endl;
else std::cout << "Not the same!" << std::endl;
return 0;
}
"The same!" should be printed out.
"Not the same!" is printed out.
g++ 4.9.3 on SUSE Linux
g++ Apple LLVM version 9.0.0 (clang-900.0.39.2) on Mac OS X
develop
branch?It's from the "develop" branch version 2.1.1.
Same problem is found in version 3.0.1
No compilation error
Feature Request
Describe the feature in as much detail as possible.
Include sample usage where appropriate.
The text was updated successfully, but these errors were encountered: