Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/cosven/april

一个失败但是还算好玩的玩具
https://github.com/cosven/april

deserialization json model python

Last synced: 14 days ago
JSON representation

一个失败但是还算好玩的玩具

Awesome Lists containing this project

README

        

# april

[![Build Status](https://travis-ci.org/cosven/april.svg?branch=master)](https://travis-ci.org/cosven/april)
[![Coverage Status](https://coveralls.io/repos/github/cosven/april/badge.svg?branch=master)](https://coveralls.io/github/cosven/april?branch=master)

lightweight & declarative model/struct representation, work as you expected it to

## Usage

### simple usage

```python
from datetime import datetime

from april import Struct

class User(Struct):
_fields = ['name', 'age', 'birthday']

user = UserModel(name='lucy', age=20, birthday='2017-09-08')
user2 = UserModel(name='hey')

class VIP(User):
_fields = ['level']

vip = VIP(user, level=1)
vip.name == lucy
user2.age is None
```

> tips: `april` usually works along with serialization library, such as [marshmallow](http://marshmallow.readthedocs.io/en/latest/quickstart.html#deserializing-to-objects)