Jpp 19.3.0-rc.2
the software that should make you happy
Loading...
Searching...
No Matches
JSON::JComparator Struct Reference

Auxiliary data structure to compare (part of) JSon data. More...

#include <JComparator.hh>

Public Member Functions

 JComparator ()
 Defaut constructor.
 
json operator() (const json &ja, const json &jb, const std::string &key) const
 Auxiliary method to compare (part of) JSon data.
 

Public Attributes

char SEPARATOR = '.'
 

Detailed Description

Auxiliary data structure to compare (part of) JSon data.

The key can be used to specify which part of the JSon data to print.
For example:

  "Error.Code"

will compare the error codes some specific JSon data.

Definition at line 29 of file JSon/JComparator.hh.

Constructor & Destructor Documentation

◆ JComparator()

JSON::JComparator::JComparator ( )
inline

Defaut constructor.

Definition at line 36 of file JSon/JComparator.hh.

37 {}

Member Function Documentation

◆ operator()()

json JSON::JComparator::operator() ( const json & ja,
const json & jb,
const std::string & key ) const
inline

Auxiliary method to compare (part of) JSon data.

Parameters
jaJSon data
jbJSon data
keykey

Definition at line 47 of file JSon/JComparator.hh.

48 {
49 using namespace std;
50
51 const size_t pos = key.find(SEPARATOR);
52
53 if (pos != string::npos) {
54 return (*this)(ja[key.substr(0,pos)], ja[key.substr(0,pos)], key.substr(pos + 1));
55 } else if (key != "") {
56 return json::diff(ja[key], jb[key]);
57 } else {
58 return json::diff(ja, jb);
59 }
60 }

Member Data Documentation

◆ SEPARATOR

char JSON::JComparator::SEPARATOR = '.'

Definition at line 31 of file JSon/JComparator.hh.


The documentation for this struct was generated from the following file: