-
Notifications
You must be signed in to change notification settings - Fork 461
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stripe events have the object property serialized twice #797
Comments
@sudhirj Thanks a lot for the report! I opened a PR for this and we'll get this released likely next week! |
@sudhirj A while back I started work on something to avoid having to manually map that Just add a cusom marshaller to the template/type check for nil pointers, and set the // add `json:"-"` to all fields, or `json:"fieldname,omitempty"`
func (e Event) MarshalJSON() ([]byte, error) {
type mEvent struct {
stripe.Event // embed the original event
Object interface{} `json:"object"`
}
me := mEvent{
Event: e.Event, // set stripe.Event
}
if e.SKU != nil {
me.Object = e.SKU
} else if e.Order != nil {
me.Object = e.Order
}
// and so on
return json.Marshal(me)
} Just like the switch in the custom So straightforward, in fact, that I've added the part to generate a custom marshaller to the template: https://gist.github.com/EVODelavega/288a109d8ed9e908c99175b75cfb70a8 I've got a
|
@sudhirj Thanks for the patience here. We just released a fix in 57.4.0 |
Bumps [webdrivers](https://github.com/titusfortner/webdrivers) from 5.0.0 to 5.1.0. - [Release notes](https://github.com/titusfortner/webdrivers/releases) - [Changelog](https://github.com/titusfortner/webdrivers/blob/main/CHANGELOG.md) - [Commits](titusfortner/webdrivers@v5.0.0...v5.1.0) --- updated-dependencies: - dependency-name: webdrivers dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
I'm serializing all the events coming in for audit purposes, and the
object
property is being represented in all serializations twice.In https://github.com/stripe/stripe-go/blob/master/event.go#L36
The
Raw
Go property is serialized once in the JSON asobject
, and theObject
Go property is serialized again asObject
in the JSON. Ideally, theObject
property should have ajson:"-"
annotation.The text was updated successfully, but these errors were encountered: