#ifndef __JSON__JCOMPARATOR__ #define __JSON__JCOMPARATOR__ #include #include #include "JSon/JSon.hh" /** * \author mdejong */ namespace JSON {} namespace JPP { using namespace JSON; } namespace JSON { /** * Auxiliary data structure to compare (part of) JSon data. * * The key can be used to specify which part of the JSon data to print.\n * For example: *
   *   "Error.Code"
   * 
* will compare the error codes some specific JSon data. */ struct JComparator { char SEPARATOR = '.'; /** * Defaut constructor. */ JComparator() {} /** * Auxiliary method to compare (part of) JSon data. * * \param ja JSon data * \param jb JSon data * \param key key */ inline json operator()(const json& ja, const json& jb, const std::string& key) const { using namespace std; const size_t pos = key.find(SEPARATOR); if (pos != string::npos) { return (*this)(ja[key.substr(0,pos)], ja[key.substr(0,pos)], key.substr(pos + 1)); } else if (key != "") { return json::diff(ja[key], jb[key]); } else { return json::diff(ja, jb); } } }; } #endif