Skip to main content

jsonModel

json数据转为实体类的工具

python版本

2.7 ~ 3.8

安装

包被上传到pypi

使用pip安装:

$ 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)

Release files for pyjsonmodel 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyjsonmodel 1.0.2
File Size Uploaded
pyjsonmodel-1.0.2.tar.gz 3.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyjsonmodel 1.0.2
File Interpreter ABI Platform
pyjsonmodel-1.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 8.2 kB

Release files / pyjsonmodel-1.0.2.tar.gz

Download URL pyjsonmodel-1.0.2.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
b24c200467b61ce0a5dd3793a9923ca650139ae2460b893262a3119198a5570c
BLAKE2b-256 checksum
How to use checksums
f4c8992d25752ff8ffa49cb85d3a3a38d11d3d08a619b164465dded8fb8eb570
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.6

Release files / pyjsonmodel-1.0.2-py3-none-any.whl

Download URL pyjsonmodel-1.0.2-py3-none-any.whl
Size 4.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4b7b494d81afaacd49b76bdc411ff820e70f460a8a1623d606e2a7196e4a6a54
BLAKE2b-256 checksum
How to use checksums
5f15bf6da92b779633748a7dac9bfa43f2282bef76f85cd88ec3cf38344ddced
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.6

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page