Evaluates the same JSON document with both resolution strategies (Expressionist::EvalMethod::GRAPH and Expressionist::EvalMethod::RECURSIVE) and prints the results.
#include <expressionist.hpp>
#include <iostream>
int main() {
const nlohmann::json input = nlohmann::json::parse(R"({
"a": 1,
"b": 2,
"c": "$a + b",
"d": "This must remain a string",
"e": "while strings beginning with $ must be evaluated",
"f": "$pi/3",
"g": "$sin(f ) * b",
"h": true,
"i": false,
"j": "$h && i"
})");
try {
std::cout <<
"GRAPH:\n" << ex.
produce().dump(2) <<
"\n\n";
std::cout <<
"RECURSIVE:\n" << ex.
produce().dump(2) <<
"\n";
} catch (const std::exception &e) {
std::cerr << "Error: " << e.what() << "\n";
return 1;
}
return 0;
}
Definition expressionist.hpp:1047
void setEvalMethod(EvalMethod method)
Definition expressionist.hpp:1125
json produce() const
Definition expressionist.hpp:1107