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

Generate "JSON encoding" functions for python types #197

Merged
merged 15 commits into from
Jan 12, 2024

Conversation

K-Phoen
Copy link
Member

@K-Phoen K-Phoen commented Dec 14, 2023

This PR generates a "to_json()" function for Python types, as well as a cog-specific JSON encoder that together will allow us to encode these types to JSON.

The encoder shipped with cog uses this to_json() function when it's available, or defaults to the standard encoder.

Intended usage:

from cog.encoder import JSONEncoder

dashboard = magical_function_to_generate_a_dashboard().build()
encoder = JSONEncoder(sort_keys=True, indent=2)

print(encoder.encode(dashboard))

@K-Phoen K-Phoen merged commit 45df64e into lang-python/__init__ Jan 12, 2024
3 of 4 checks passed
@K-Phoen K-Phoen deleted the lang-python/to_json branch January 12, 2024 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants