-
Notifications
You must be signed in to change notification settings - Fork 77
Closed
Description
Is your feature request related to a problem? Please describe.
I'd like to have cbor marshal a struct but omit certain fields.
Describe the solution you'd like
Add a new strut tag, perhaps simply omit, that tells cbor not to marshal a field. It'd look something like this:
type Entity struct {
_ struct{} `cbor:",toarray"`
ID uint64 `json:"id"`
Type string `cbor:",omit" json:"typeOf"`
Name string `json:"name"`
}When cbor marshals an instance of this strut, it would include data for ID and Name but not Type.
Describe alternatives you've considered
I'm currently managing this by using an inner struct that contains just the fields I want marshaled and just marshaling it in MarshsalCBOR. This works, but conflicts with the JSON marshaling, in which I want to include Type.
Perhaps I'm missing some other solution, though. Thanks!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels