-
Notifications
You must be signed in to change notification settings - Fork 122
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Is there an existing feature request for this?
- I have searched the existing feature requests
Description
Hello! I'm using your client and it rocks! The only issue is, I'm not sure how to serialize it to JSON.
I notice that your model classes extend DataClassJSONMixin, and have a to_json method, but I get an error when I execute that method because SnykClient tries to get serialized. Maybe you should implement a custom __getstate__ and __setstate__ or something for unpickleable attributes?
Example:
import os
import snyk
import json
class SnykClient:
def __init__(self):
self.client = snyk.SnykClient(os.environ.get('SNYK_API_KEY'))
def get_all_projects(self):
all_projects = self.client.projects.all()
return all_projects
if __name__ == "__main__":
client = SnykClient()
all_projects = client.get_all_projects()
print(all_projects)
# save to json file
with open('all_projects.json', 'w') as f:
all_projects_jsonified = [project.to_json() for project in all_projects]
json.dump(all_projects_jsonified, f)
Additional Information
No response
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request