1
0
mirror of https://github.com/eternnoir/pyTelegramBotAPI.git synced 2023-08-10 21:12:57 +03:00

Merge pull request #191 from Ledokol/uni-json

unicode strings for check_json
This commit is contained in:
FrankWang 2016-06-05 18:36:36 +08:00
commit b528b0bcf0

View File

@ -62,9 +62,14 @@ class JsonDeserializable:
:param json_type:
:return:
"""
try:
str_types = (str, unicode)
except NameError:
str_types = (str,)
if type(json_type) == dict:
return json_type
elif type(json_type) == str:
elif type(json_type) in str_types:
return json.loads(json_type)
else:
raise ValueError("json_type should be a json dict or string.")