文件 https://marshmallow.readthedocs.io/en/stable/
安裝套件
pip install -U marshmallow
- 反序列化 (Loading)
Deserialize input data to app-level objects.
The reverse of the dump method is load,
which validates and deserializes an input dictionary to an application-level data structure
- 序列化 (Dumping) obj -> dict
Serialize app-level objects to primitive Python types.
The serialized objects can then be rendered to standard formats
such as JSON for use in an HTTP API.
範例 demo.py
python3 demo.py
讀取 json 並且驗證資料 validating_package.py
python3 validating_package.py
更多例子 https://marshmallow.readthedocs.io/en/stable/examples.html