I need to get an item from the mongo database, so I defined a structure like this
type Page struct { PageId string `bson:"pageId"` Meta map[string]interface{} `bson:"meta"` }
Now I also need to encode it in JSON, but it encodes the fields as uppercase (I get PageId instead of pageId), so I also need to define field tags for JSON. I tried something like this, but this did not work:
type Page struct { PageId string `bson:"pageId",json:"pageId"` Meta map[string]interface{} `bson:"meta",json:"pageId"` }
So, how can this be done by defining several name tags in the structure?
json struct go
Sofia 05 Sep '13 at 11:56 on 2013-09-05 11:56
source share