Pass the type as a string via an HTTP header The decoder side of the request/response cycle, decodes the JSON according to the type in the header 'x-body-type': 'BasicReq' you would store BasicReq in a map of `<string,Class>` or `<string,struct>`