how does gorm create data for json fields?
the official document has an example of creating a record: http://gorm.io/zh_CN/docs/ind.
//
db.Create(&Product{Code: "L1212", Price: 1000})
question:
if this Product model has a specification (Spec) field, which is in json format, there are three items:
{
"length":"20cm",
"width":"30cm",
"weight":"40g"
}
how should I write this creation statement? If you write IDE like this, you will get an error:
//
db.Create(&Product{Code: "L1212", Price: 1000,Spec:{"length":"20cm","width":"30cm","weight":"40g"}})