samedi 15 juin 2019

C++ reflection and to/from key value pair (like json)

I found this answer to kind of do reflection in C++: https://stackoverflow.com/a/11748131/5507357

However, I would like to 'expand' this to do 'deserialization'. So for example, I have a json Person object

{ 
    "Person": 
    { 
        "name": "Tom",
        "age": 82
    }
}

Or an ini file, or xml. How can I create a Person struct with these values with this reflection? The code does not have to 'detect' it is a Person object, it is all about the members.





Aucun commentaire:

Enregistrer un commentaire