problems unmarshaling JSON to struct; panic: interface conversion: interface {} is string, not []uint8 #275
-
I did some testing, and I can unmarshal a string which is a JSON array of tuples, into a custom struct. But trying to write a custom Scanner doesn't work. Test code as follows:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
oh, I realised if I convert to []byte first the Scan works, i.e. But this same custom Scan doesn't seem to work when I use it with go-jet to parse a JSON result. I am generating the json string as the result of: and using that within a stmt, e.g.:
Is the SQL result not a []byte already? |
Beta Was this translation helpful? Give feedback.
-
my current workaround is to change the scanner to:
|
Beta Was this translation helpful? Give feedback.
I think that
value
type depends on the driver used. To be safe you can handle both cases, for string and []byte: