This is an idea that I had a while ago, and I'm assuming that it will be a lot faster than var:
mixed.hpptypes.hpp (has a lot of stuff that is not required for the above)
Unsigned char and char are treated as separate types to dictate which should be displayed as a character and which should be displayed as a number.
I use types.hpp for a lot, which is why it has loads of comments (mixed.hpp would have the same thing but I'm lazy right now). I just made mixed.hpp in about ten minutes.
tl;dr for the code: it stores void *value and uint8_t type, the void pointer storing the value of the type, and the integer to decide which type that it is, as opposed to creating a separate value for double and string within a structure and returning whichever one depending on which is requested.