mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-12 07:02:14 +08:00
22 lines
355 B
Python
22 lines
355 B
Python
#!/usr/bin/python
|
|
# -*- coding: UTF-8 -*-
|
|
|
|
import json
|
|
|
|
|
|
def to_json_string(obj):
|
|
"""将对象转换成json字符串
|
|
|
|
:param obj: 对象
|
|
:type obj: object
|
|
|
|
:return: 返回json
|
|
:rtype: str
|
|
"""
|
|
if isinstance(obj, dict):
|
|
param = obj
|
|
else:
|
|
param = obj.__dict__
|
|
return json.dumps(param, ensure_ascii=False)
|
|
|