mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 21:57:56 +08:00
3.2.0
This commit is contained in:
21
sop-sdk/sdk-python/common/JsonUtil.py
Normal file
21
sop-sdk/sdk-python/common/JsonUtil.py
Normal file
@@ -0,0 +1,21 @@
|
||||
#!/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)
|
||||
|
Reference in New Issue
Block a user