Convert C++ class with 150+ variables to Json object -
i codding in c++ , using jsoncpp. have class 150+ variables , know if possible convert variables json @ once. not :
myclass.h
class myclass { std::string var0; std::string var1; //... std::string var150; }
main.cpp
int main() { json::value param; param["var0"] = var0; param["var1"] = var1; //... param["var150"] = var150; }
thanks tips.
one option create structure in google protocol buffers. you'll still need list members once (in .proto file instead of .cpp file) can use protobuf library to convert or json, , has other handy abilities (e.g. iterate on members, convert binary format, use grpc).
Comments
Post a Comment