Skip to main content
Donate to the Python Software Foundation or Purchase a PyCharm License to Benefit the PSF! Donate Now

serialize a object | 简易对象序列化工具

Project description


简易对象序列化工具 serialize a object

$ pip install easyserializer

from easyserializer import *
import datetime

class Student(object):
    role = 'student'

    def __init__(self, name, birthday): = name
        self.birthday = birthday

    def age(self):
        return int((( - self.birthday).days) / 365)

class Teacher(SerializeableObject):
    role = 'teacher'

    def __init__(self, name, subject, students): = name
        self.subject = subject
        self.students = students

s0 = Student('Dad',, 7, 28))
s1 = Student('Mom',, 11, 2))
t = Teacher('Tao', 'physics', [s0, s1])


print(t.to_json(prune=True, limit_deep=2, indent=4))

print(serialize(t, filter_fields=['name', 'students']))

print(obj_to_json(s1, exclude_fields=['role']))

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
easyserializer-0.2.7.tar.gz (3.1 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page