Skip to content

Json与Python对象的双向绑定(jsonfy) Jsonfy: Lightweight two-way binding of JSON and object without third-party dependency

License

Notifications You must be signed in to change notification settings

liangbaika/jsonfy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

1. Jsonfy: Lightweight two-way binding of JSON and object without third-party dependency

2. pip install jsonfy

3. How to use? you can see examples or Quick start

4. Welcome to submit your code and comments to a better Jsonfy

5. Quick start:

import time
from datetime import datetime
from cn.jsonfy.core import DateTimeDesc, BaseJsonModel, DictDesc

class Foo(BaseJsonModel):
    infos1 = DictDesc("infos1")
    up = DateTimeDesc("up", format='%Y-%m-%d')
    down = DateTimeDesc("down")
    
    
if __name__ == '__main__':
    f = Foo()
    _fake_time = datetime.now()
    f.up = _fake_time
    f.down = _fake_time
    _dict = {"key": "value"}
    f.infos1 = _dict
    
    print(f.toJson())
    f_obj = f.fromJson(f.toJson())
    print(f_obj)

About

Json与Python对象的双向绑定(jsonfy) Jsonfy: Lightweight two-way binding of JSON and object without third-party dependency

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages