summaryrefslogtreecommitdiffstats
path: root/api/utils/common.py
diff options
context:
space:
mode:
authorchenjiankun <chenjiankun1@huawei.com>2016-11-30 07:28:36 +0000
committerchenjiankun <chenjiankun1@huawei.com>2016-11-30 07:28:36 +0000
commit1558bcf48bdba369187d7cb07482f2fbcc6f4feb (patch)
treea18ac011457cf219503bbeb79d83662bb2f67b4a /api/utils/common.py
parented89d5d7372b598a3b849f7753e8d29a39282d53 (diff)
Use flask jsonify method to return json result
JIRA: YARDSTICK-433 Python json lib is very hard to parse when transport via network. Flask jsonfiy is more easier to use. Change-Id: I2afd5238d65bc474170c57d2f9307dc881ea4990 Signed-off-by: chenjiankun <chenjiankun1@huawei.com>
Diffstat (limited to 'api/utils/common.py')
-rw-r--r--api/utils/common.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/api/utils/common.py b/api/utils/common.py
index 09cfc04d4..e3e64a72b 100644
--- a/api/utils/common.py
+++ b/api/utils/common.py
@@ -8,7 +8,8 @@
##############################################################################
import collections
import logging
-import json
+
+from flask import jsonify
from api.utils.daemonthread import DaemonThread
from yardstick.cmd.cli import YardstickCLI
@@ -50,7 +51,7 @@ def error_handler(message):
'status': 'error',
'message': message
}
- return json.dumps(result)
+ return jsonify(result)
def result_handler(status, data):
@@ -58,7 +59,7 @@ def result_handler(status, data):
'status': status,
'result': data
}
- return json.dumps(result)
+ return jsonify(result)
class Url(object):