Skip to main content


Project description




2.7 ~ 3.8




$ pip install pyjsonmodel

或 更新包

$ pip install pyjsonmodel --update


# 模型
class GModel:
    sss = None

class ZModel:
    aaa = None

class People:
    name = None
    age = None
    girlFriends = None
    zzz = None
    testList = None

    # 这里指定属性类型
    __doc__ = {
        "girlFriends": GModel,
        "zzz": ZModel

# 引用
import jsonModel

data = '[{"testList":[1, 2, 3],"name":"jack","age":13,"girlFriends":[{"sss":"111"},{"sss":"222"}],"zzz":{"aaa":"aaa"}},{"testList":[1, 2, 3],"name":"jone","age":21,"girlFriends":[{"sss":"111"},{"sss":"222"}],"zzz":{"aaa":"aaa"}}]'

# json 转 实体类
res = jsonModel.loads(data, People)

# 实体类 转 json
jsonStr = jsonModel.dumps(res)

Project details

Download files

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

Files for pyjsonmodel, version 1.0.2
Filename, size File type Python version Upload date Hashes
Filename, size pyjsonmodel-1.0.2-py3-none-any.whl (4.5 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size pyjsonmodel-1.0.2.tar.gz (3.7 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page