-1

I was trying few exapmles using beego with mongo. you can find my source at : https://github.com/wsourabh/bapi

but while calling the v1/accounts/:id

I am always getting the response as

curl -v localhost:8080/v1/accounts/0df542560fbfc39a4bdb24d0ca44d37e
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET /v1/accounts/0df542560fbfc39a4bdb24d0ca44d37e HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.43.0
> Accept: */*
> 
< HTTP/1.1 200 OK
< Content-Length: 46
< Content-Type: application/json; charset=utf-8
< Server: beegoServer:1.6.1
< Date: Tue, 17 May 2016 18:53:50 GMT
< 
{
  "Id": "0df542560fbfc39a4bdb24d0ca44d37e"
* Connection #0 to host localhost left intact
}

other fields are coming as blank. can someone guide me how to do it correctly.

I want to have output something like

{
"_id":"account_id",
"created":"created_date",
"updated":"updated_date",
"email": "wsourabh@aaa.com"
"wcd_guid" : "some_id"
"name":
    {
      "full" :"sourabh J",
      "last" : "J",
      "first" :"sourabh"
     }
"country": "IN",
"status": "new"
}

while enabling the debug for mgo , I am getting the debug log as :

MGO: session.go:3062: Query 0xc820378900 document unmarshaled: &models.Accounts{Id:"0df542560fbfc39a4bdb24d0ca44d37e", created:"", updated:"", email:"", wcd_guid:"", name:(*models.Name)(nil), country:"", status:""}
4

1 回答 1

0

阅读 beego 的文档和示例。为了提供 json,您必须向json模型添加标签。

如果这不能解决您的问题,则意味着 beego 会自动从您的结构中删除零值,以免被编组。在这种情况下,你更有可能从 beego 的开发者那里找到帮助,而不是从 StackOverflow 那里。

于 2016-05-18T02:09:06.777 回答