Questions about beego curd Values method

I get some map by using the Values method

var radio []orm.Params
num, _ := orm.NewOrm().
            QueryTable("product_album").
            Filter("product_id", id).
            Filter("state", 1).
            Values(&radio)

but the first letter of the result is all uppercase. I have set the lowercase rule in model

type ProductAlbum struct {
    Id   int `json:"id"`
    ProductId int `json:"product_id"`
    Name string `json:"name"`
    Url  string `json:"url"`
    State string `json:"state"`
}

result of error

"radio": [
      {
        "Id": 37,
        "Name": "",
        "ProductId": 9,
        "State": "0",
        "Url": "7d9006e1d73d527662e598c1856327f28742"
      },
      {
        "Id": 55,
        "Name": "",
        "ProductId": 9,
        "State": "0",
        "Url": "38909849c3289db116c020c3d34cfb6f3975"
      },
      {
        "Id": 56,
        "Name": "",
        "ProductId": 9,
        "State": "0",
        "Url": "a164deb99004f9647f87f21771d19b468181"
      }
    ]

expected results

"radio": [
      {
        "id": 37,
        "name": "",
        "productId": 9,
        "state": "0",
        "url": "7d9006e1d73d527662e598c1856327f28742"
      },
      {
        "id": 55,
        "name": "",
        "productId": 9,
        "state": "0",
        "url": "38909849c3289db116c020c3d34cfb6f3975"
      },
      {
        "id": 56,
        "name": "",
        "productId": 9,
        "state": "0",
        "url": "a164deb99004f9647f87f21771d19b468181"
      }
    ]

ask the boss to give us some advice, thank you

Oct.19,2021

orm: "column (id)"; json: "id" so


use json to turn around

package main

import (
    "fmt"
    "gopkg.in11/square/go-jose.v2/json"
)

type ProductAlbum struct {
    Id   int `orm:"column(id)" json:"id"`
    ProductId int `json:"product_id"`
    Name string `json:"name"`
}

func main() {
    p := ProductAlbum{Id:1,ProductId:2,Name:""}

    json_ret,err := json.MarshalIndent(p,""," ")
    fmt.Println(err)
    fmt.Println(string(json_ret))

}

image.png

Menu