Skip to content

Instantly share code, notes, and snippets.

@podhmo

podhmo/05encode.py

Created May 6, 2021
Embed
What would you like to do?
import dataclasses
import enum
import jsonpickle
class Status(enum.Enum):
x = enum.auto()
y = enum.auto()
z = enum.auto()
@dataclasses.dataclass
class A:
name: str
age: int
status: Status
a = A(name="foo", age=0, status=Status.y)
print(jsonpickle.encode(a))
print(jsonpickle.decode(jsonpickle.encode(a)))
print(jsonpickle.decode(jsonpickle.encode(a)) == a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment