4

I have two RapidJSON documents. One I created at runtime and other one is read from disk.

I want to compare if these two documents are similar or not. What is the best way to compare RapidJSON documents?

My JSON looks like this

{
    "SimpleCompany:Manager":
    {
        "read":true,
        "update":true,
        "delete":true,
        "insert":true
    },
    "SimpleCompany:Manager":
    {
        "read":true,
        "update":true,
        "delete":true,
        "insert":true
    },
}
Sander
  • 3,942
  • 2
  • 17
  • 22
Muhammad Zaighum
  • 560
  • 4
  • 21
  • what do you want to hear? Are they strings? Hash them maybe? – Theolodis Jul 23 '14 at 11:49
  • yes these are values are strings... I just want to read those value and match them with my other Json document object. is these any build in function that can compare two json objects ? – Muhammad Zaighum Jul 23 '14 at 11:51
  • Currently we are working on a branch to provide `Value::operator==()` at https://github.com/miloyip/rapidjson/issues/91 – Milo Yip Aug 07 '14 at 02:33
  • Did you ever get this working? When I try to compare strcmp(newDocument["read"] , origDocument["read"])) I' getting //error no operator [] matches these operands. I get that when I try to do this too const rapidjson::Value& a1 = newDocument["read"]; – Michele Feb 15 '17 at 21:07

1 Answers1

0

Yes, now, GenericValue overrides the operator== with other values, strings or primitives:

bool operator==(const GenericValue<...>& rhs) const;
bool operator==(const Ch* rhs) const;
bool operator==(const std::basic_string<Ch>& rhs) const;
bool operator==(const T& rhs) const;
Alexandru Irimiea
  • 2,513
  • 4
  • 26
  • 46