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

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -