Added static annotations

This commit is contained in:
marek.piotrowski 2023-07-20 00:19:21 +02:00
parent d4a49deb83
commit 6127552b8a

View File

@ -19,11 +19,30 @@ public:
property3, "comment3");
};
class AnotherExampleClass {
private:
int property1{1};
double property2{2.5};
std::string property3{"test"};
std::map<std::string, int> property4{{"x", 1}, {"y", 2}};
std::vector<double> property5{1.5, 5.4, 3.2};
public:
AnotherExampleClass() = default;
NLOHMANN_DEFINE_TYPE_INTRUSIVE_ANNOTATED(AnotherExampleClass, property1, "comment11",
property2, "comment22",
property3, "comment33");
};
int main() {
std::cout << "Hello, world!" << std::endl;
ExampleClass ec;
AnotherExampleClass aec;
nlohmann::json j = ec;
std::cout << j.dump_annotated<ExampleClass>() << std::endl;
nlohmann::json j2 = aec;
std::cout << j2.dump_annotated<AnotherExampleClass>() << std::endl;
return 0;
}