wuranxu / oson

This is a package for encode python objects with json.(将Python对象转为json对象)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

中文说明

Desc

It's a library for python users to encode python objects to json.Use it just like use default json library.

Install

pip3 install oson

Unusual Usage

from datetime import datetime
import oson

class Student(object):
    name = 'Tom'
    age = 23
    update_at = datetime.now()
    __private = "don't see it"

s = Student()
print(oson.dumps(s))

More

from datetime import datetime
import oson

class Student(object):
    name = 'Tom'
    age = 23
    update_at = datetime.now()
    __private = "don't see it"

oson.set_config(time_format='%Y-%m-%d %H:%M:%S', date_format='%Y-%m-%d %H:%M:%S', private=False)

s = Student()
print(oson.dumps(s))

Config

  • private

    if you need to encode private column, set it True.

  • time_format

    use it to transfer time from datetime to time string

  • date_format

    just like 『time_format』

GOOD LUCK!

About

This is a package for encode python objects with json.(将Python对象转为json对象)

License:MIT License


Languages

Language:Python 100.0%