Skip to content

Equality operator fails #931

@axx

Description

@axx

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;
}

  • What is the expected behavior?

"The same!" should be printed out.

  • And what is the actual behavior instead?

"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

  • Did you use a released version of the library or the version from the 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions