VirusTotal / vt-py

The official Python 3 client library for VirusTotal
https://virustotal.github.io/vt-py/
Apache License 2.0
531 stars 121 forks source link

fix(object): Object of type WhistleBlowerDict is not JSON serializable #177

Closed mgmacias95 closed 7 months ago

mgmacias95 commented 7 months ago

closes #176

The json.dumps function only accepts native types by default (i.e. list, dict, str, int, etc etc) but it is not prepared to parse user custom types such as UserDict. To parse custom types, it is required to extend the default JsonEncoder class available at the json module. This PR does this, and integrates it into the aiohttp's client session.

This PR also updates the tests to support this use case since the problem was not the dictionary representing the object itself but the context_attributes dictionary inside the object which is an instance of the WhistleBlowerDict class.