def _get_json_to_kwargs(self, json_data):
"""
Augments json data before passing to the handler script.
Prefixes all keys with cbot_ value to avoid clashes + serializes
itself to JSON - for JSON parsing stuff.
:param json_data:
:return:
"""
n_data = OrderedDict()
for k in json_data:
val = json_data[k]
if k == 'command':
continue
if isinstance(val, float):
val = str(math.ceil(val))
if not isinstance(val, (str, basestring)):
val = str(val)
if val is not None:
n_data[k] = val
n_data['cbot_' + k] = val
n_data['cbot_json'] = self._json_dumps(json_data)
return n_data
评论列表
文章目录