Chlumsky/json-cpp-gen

Custom general type

Chlumsky opened this issue · 0 comments

Another idea I had was to support miscellaneous types in the structures, in different ways:

Converted type

This way, a type in the structure would be converted from / to a type supported by the generator. For example a timestamp type, represented by a string in the JSON, and able to be converted from / to a std::string. Each type like this would have an API template for both conversions.

Custom parse / serialize implementation

Another possibility would be that the custom type would have to provide an implementation of the parse and serialize functions of itself. This option is just an idea and probably should not be implemented.

String conversion

A sort-of hybrid between the two previous options (and raw JSON string #32) would be a type that would parse / serialize itself but not directly. Instead the parser / serializer would first construct a string object and use that to interface with the custom type's API. This would be another way to implement custom number types (#35) if they provide a conversion from / to string.