First-time poster here, and I desperately need help.
I have an API that my code is getting responses from and a few fields are not strongly typed and I need to figure out a way to unmarshal those in a manner that makes them usable by xorm.
As you can see the colors field in the json can either be of type string or type string when it comes to marshaling into the struct.
Clearly, this can’t be done in a straight forward fashion and so an interface must be used to allow for the non-type-safe field.
However, xorm (understandably) can’t translate an empty interface to a column type nor can it do so with json.RawMessage and make the data meaningful.
Sadly I don’t have control over the API and how it returns the response or this would be very simple.
Does anyone here know of a way that you can define the type post unmarshaling and still keep it within a usable format for DB insertion?
Any help would be incredibly appreciated as I’ve been banging my head on this problem for a while now.
Thanks in advance,