Converting any struct to json automatic in C++
问题 I am willing to convert any struct to json automatic without repeating code or variables in C++. Desired result: typedef JsonStruct<string, name, int, age> Person; // not have to be template... Person person; person.name = "Jacob"; person.age = 16; json personAsJson = person.toJson(); Person newPerson = Person::fromJson(personAsJson); assert(newPerson == person); I found this answer: https://stackoverflow.com/a/34165367/13277578 Which is really cool! but you still have to repeat the variable