I'm wondering if it is possible to decode a JSON object into struct based on prefix.
For example, I may have two JSON objects like following:
{ "id teacher": "10" } and
{ "id student": "20" } Currently I have two structs:
type Teacher struct { Id string `json:"id teacher"` } type Student struct { Id string `json:"id student"` } I'm wondering if it is possible to have one struct and decode based on the prefix of the string (for example, by regex id.*) assuming that there will be only one matching field.
structof unknown type. What are you really trying to do here?structof unknown type"?