Module: check_mk
Branch: master
Commit: 44997e5af743ff998c180039446748cfe9a5169d
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=44997e5af743ff…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Apr 13 14:32:21 2015 +0200
Using json module without fallback now, because simplejson is now shipped with OMD
---
web/htdocs/webapi.py | 21 ++++++---------------
1 file changed, 6 insertions(+), 15 deletions(-)
diff --git a/web/htdocs/webapi.py b/web/htdocs/webapi.py
index 9d74ec5..35eb977 100644
--- a/web/htdocs/webapi.py
+++ b/web/htdocs/webapi.py
@@ -35,6 +35,11 @@ try:
except NameError:
from sets import Set as set
+try:
+ import simplejson as json
+except ImportError:
+ import json
+
api_actions = {}
loaded_with_language = False
@@ -83,20 +88,8 @@ def page_api():
if api_actions[action].get("dont_eval_request"):
request_object = html.var("request")
else:
- eval_function = None
request = html.var("request")
-
- try:
- import json
- eval_function = json.loads
- except ImportError:
- eval_function = literal_eval
- # modify request so it can be read by literal_eval...
- for old, new in [ (": null", ": None"),
- (": true", ": True"),
- (": false", ": False"), ]:
- request = request.replace(old, new)
- request_object = eval_function(request)
+ request_object = json.loads(request)
else:
request_object = {}
@@ -111,8 +104,6 @@ def page_api():
output_format = html.var("output_format", "json")
if output_format == "json":
- # TODO: implement json alternative for python < 2.5
- import json
html.write(json.dumps(response))
else:
html.write(repr(response))