Skip to content

Instantly share code, notes, and snippets.

@Kos
Created April 24, 2021 18:23
Show Gist options
  • Save Kos/5174f44573a39560c41e750dd5bfb0b1 to your computer and use it in GitHub Desktop.
Save Kos/5174f44573a39560c41e750dd5bfb0b1 to your computer and use it in GitHub Desktop.
def book_to_json(book: Book):
return {
"isbn": book.isbn,
"title": book.title,
"author": book.author,
}
def book_from_json(data: dict) -> Book:
return Book(
isbn=data["isbn"],
title=data["title"],
author=data["author"],
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment