Answer the question
In order to leave comments, you need to log in
How to properly handle outgoing B24 webhook data in python?
The python application processes the outgoing Bitrix24 webhook.
From request.form I get a dictionary of such key-value pairs: {
'
data[PARAMS][CHAT_ENTITY_DATA_1]' : '...'
}
CHAT_ENTITY_DATA_1' : '...' } } }
Answer the question
In order to leave comments, you need to log in
eval is:
import ast
inpt = { 'data[PARAMS][CHAT_ENTITY_DATA_1]' : '...' ,
'data[PARAMS][CHAT_ENTITY_DATA_2]' : '...' ,
'data[PARAMS][CHAT_ENTITY_DATA_3]' : '...' }
results = []
for k, v in inpt.items():
print(k,v)
# корячим входную строку как нам нужно:
r_str = "{'" + k.replace("[","':{'").replace("]","") + "':'" + v + "'}}}"
print('строка ', r_str)
print(type(r_str))
# с помощью eval превращаем строку в словарь:
r = ast.literal_eval(r_str)
print('словарь ', r_str)
print(type(r))
results.append(r)
print('\nрезультат\n', results)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question