Skip to content
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

Arrays in webhooks previous attributes parsed as Object[] #605

Closed
Flo354 opened this issue Oct 16, 2018 · 5 comments · Fixed by #700
Closed

Arrays in webhooks previous attributes parsed as Object[] #605

Flo354 opened this issue Oct 16, 2018 · 5 comments · Fixed by #700
Assignees
Labels

Comments

@Flo354
Copy link

Flo354 commented Oct 16, 2018

Hi,

I am using stripe-java version 7.1.0 and I am currently experiencing something weird with Webhooks.
When getting event.getData().getPreviousAttributes(), I obtain a Map<String, Object> which is fine.

Within this map, if I am getting the field verification, is it also a Map<String, Object>.
But why an array, like verification -> fields_needed is an Object[] instead of a List<Object>.

Actually, I am asking this question to myself, because with my JSON library (Jackson JSON), When I am using this code:

String jsonStr = "some json";
Map<String, Object> result = mapper.readValue(jsonStr, Map.class);

When I am recovering verification -> fields_needed, I am getting an ArrayList<Object>. And I find this more natural.

@ob-stripe
Copy link
Contributor

Hi @Flo354, thanks for the report!

Stripe's Java library uses a custom deserializer for the data attribute of event objects. It is this custom deserializer that decodes JSON lists as Java arrays instead of List objects (cf. here).

I agree that List objets would feel more natural here and be more consistent with the rest of the API, so I'd be inclined to change the behavior here. Such a change would break backwards compatibility, but I think we were planning on releasing a new major version soon anyway, so we could bundle this change too.

@brandur-stripe @remi-stripe Any strong feels around this?

@remi-stripe
Copy link
Contributor

I agree that List would make a lot more sense and I would tag as Future for when we do the next major revision.

@Flo354
Copy link
Author

Flo354 commented Oct 16, 2018

Thanks!

I'll wait for the next major release.

@ob-stripe
Copy link
Contributor

Quick update: this didn't make it into the newly released major version 8.0.0, but it's still on our roadmap and will be fixed in a future major version.

@ob-stripe
Copy link
Contributor

Fixed in stripe-java 9.0.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants