MCPcopy Index your code
hub / github.com/eternnoir/pyTelegramBotAPI / check_json

Method check_json

telebot/types.py:92–108  ·  view source on GitHub ↗

Checks whether json_type is a dict or a string. If it is already a dict, it is returned as-is. If it is not, it is converted to a dict by means of json.loads(json_type) :meta private: :param json_type: input json or parsed dict :param dict_copy: if dict is

(json_type, dict_copy = True)

Source from the content-addressed store, hash-verified

90
91 @staticmethod
92 def check_json(json_type, dict_copy = True):
93 """
94 Checks whether json_type is a dict or a string. If it is already a dict, it is returned as-is.
95 If it is not, it is converted to a dict by means of json.loads(json_type)
96
97 :meta private:
98
99 :param json_type: input json or parsed dict
100 :param dict_copy: if dict is passed and it is changed outside - should be True!
101 :return: Dictionary parsed from json or original dict
102 """
103 if service_utils.is_dict(json_type):
104 return json_type.copy() if dict_copy else json_type
105 elif service_utils.is_string(json_type):
106 return json.loads(json_type)
107 else:
108 raise ValueError("json_type should be a json dict or string.")
109
110 def __str__(self):
111 d = {

Callers 15

de_jsonMethod · 0.80
de_jsonMethod · 0.80
de_jsonMethod · 0.80
de_jsonMethod · 0.80
de_jsonMethod · 0.80
de_jsonMethod · 0.80
de_jsonMethod · 0.80
de_jsonMethod · 0.80
de_jsonMethod · 0.80
de_jsonMethod · 0.80
de_jsonMethod · 0.80
de_jsonMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected