Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

details.all is not json serializable because of the ip_address object #8

Closed
coderholic opened this issue Nov 5, 2018 · 3 comments · Fixed by #14
Closed

details.all is not json serializable because of the ip_address object #8

coderholic opened this issue Nov 5, 2018 · 3 comments · Fixed by #14
Assignees

Comments

@coderholic
Copy link
Member

No description provided.

@bartbroere
Copy link
Contributor

For anyone googling this: The key ip_address contains an instance of IPv4Address, and the key ip contains the IP address encoded as a string. To be able to serialize this in json, you could simply drop the key ip_address with the del keyword.

import json
import ipinfo

handler = ipinfo.getHandler("deadbeef")

ip_details = handler.getDetails("8.8.8.8")
del ip_details["ip_address"]
ip_details_serialized = json.dumps(ip_details)

@UmanShahzad
Copy link
Contributor

UmanShahzad commented Jun 13, 2019

I think we could probably just avoid inserting the IPv4Address type object in there so that it's just the string you get from the ip field via the API's JSON response. Though we'd have to bump the major version because people may be relying on it being IPv4Address type.

@UmanShahzad
Copy link
Contributor

Released https://pypi.org/project/ipinfo/2.0.0/ without the ip_address key, and with a changelog entry in https://github.com/ipinfo/python/blob/master/CHANGELOG.md.

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

Successfully merging a pull request may close this issue.

3 participants