The project page with details is available at:
The following changes were made in release r2011.08.02.
- The tag format for marshalled fields has been changed to
follow the conventions established in release r59 of Go.
The key name within the tag is now separated from flags
using a comma, and flags have also been renamed.
Here is a simple table for migration:
"/c" => ",omitempty"
"/s" => ",minsize"
"/cs" => ",omitempty,minsize"
"key" => "key"
"key/c" => "key,omitempty"
"key/s" => "key,minsize"
"key/cs" => "key,omitempty,minsize"
If provided with an old-styled tag, gobson will panic
reporting the problem and will also inform the new
spelling for the specific tag at hand.
For more details, please see the documentation:
http://goneat.org/lp/gobson/bson#Marshal
http://goneat.org/lp/gobson/bson#Unmarshal
- The bson tag information can now be namespaced. For
example, the following is a valid tag with information for
both the json and the bson packages:
`bson:",omitempty" json:",omitempty"`
Using the bson namespace is optional as long as the
content of the tag, which should be fully oriented towards
gobson, does not contain the ":" character.
- To improve consistency in the naming convention, the recently
introduced GetRef methods have been renamed to FindRef, and
GetLiveServers was renamed to LiveServers:
http://goneat.org/lp/mgo#Session.FindRef
http://goneat.org/lp/mgo#Database.FindRef
http://goneat.org/lp/mgo#Session.LiveServers
- New ObjectId.Hex method to obtain the commonly wanted hex
representation of the id, as requested by Travis Reeder:
http://goneat.org/lp/gobson/bson#ObjectId.Hex
- ObjectId pointers may now be marshalled and unmarshalled
properly by the json package, also requested by Travis:
http://goneat.org/lp/gobson/bson#ObjectId.MarshalJSON
http://goneat.org/lp/gobson/bson#ObjectId.UnmarshalJSON
- New DatabaseNames and CollectionNames methods, as requested
by Fabian Reinartz:
http://goneat.org/lp/mgo#Session.DatabaseNames
http://goneat.org/lp/mgo#Database.CollectionNames
- New GridFile.UploadDate method, also requested by Fabian:
http://goneat.org/lp/mgo#GridFile.UploadDate
--
Gustavo Niemeyer
http://niemeyer.net
http://niemeyer.net/plus
http://niemeyer.net/twitter
http://niemeyer.net/blog
-- I never filed a patent.
I've got one further request here. Can these methods have value
receivers instead of pointer receivers?
As it is, if I have a struct with an ObjectId field, json fails to
marshal unless I turn the field into a pointer, which I'd prefer not
to do. With that small change, json marshals both pointers and values
correctly. (I haven't tested unmarshalling yet, but I assume it has
the same problem.)
- Evan
> I've got one further request here. Can these methods have value
> receivers instead of pointer receivers?
>
> As it is, if I have a struct with an ObjectId field, json fails to
> marshal unless I turn the field into a pointer, which I'd prefer not
I lost that request somehow when you mentioned it last month, but
looking over the list for pending things I got it, and will be in the
next release.
> to do. With that small change, json marshals both pointers and values
> correctly. (I haven't tested unmarshalling yet, but I assume it has
> the same problem.)
No, unmarshalling cannot change in that regard, otherwise we'd be
unable to set the id field to the unmarshalled value.
Thanks!
>> to do. With that small change, json marshals both pointers and values
>> correctly. (I haven't tested unmarshalling yet, but I assume it has
>> the same problem.)
>
> No, unmarshalling cannot change in that regard, otherwise we'd be
> unable to set the id field to the unmarshalled value.
I realized that after I sent the email, but hoped you'd figure it out. ;)
- Evan