我有两个名为“Invoices”、“Transactions”的结构。这些是 GORM 模型。我想合并这些结构并转换 json。
例子:
type Invoice struct {
gorm.Model
DocType string `json:"docType"`
Total float64 `json:"total"`
}
type Transaction struct {
gorm.Model
DocType string `json:"docType"`
Total float64 `json:"total"`
Account uint `json:"account"`
}
我想像这样回应;
[
{docType:"invoice", total: "123.00"}
{docType:"transaction", account:"1", total: "124.00"}
{docType:"invoice", total: "125.00"}
]
繁花不似锦
相关分类