Oct-23-2024, 08:29 PM
(This post was last modified: Oct-24-2024, 08:02 AM by Larz60+.
Edit Reason: added output keys
)
Hi,
Am trying to extract a specific field in JSON in python and process it further to send output in e-mail. The problem am facing am able to get the messageId, but nothing else works. Am trying to get userid and phoneno value into variable and use it for further processing, but the output is empty.
But if I try to get messageID, it works, the output is value of messageId
us = data_dict.get('messageId')
print us
Any other key I try to extract doesn't work, any help would be great!
Am trying to extract a specific field in JSON in python and process it further to send output in e-mail. The problem am facing am able to get the messageId, but nothing else works. Am trying to get userid and phoneno value into variable and use it for further processing, but the output is empty.
But if I try to get messageID, it works, the output is value of messageId
us = data_dict.get('messageId')
print us
Any other key I try to extract doesn't work, any help would be great!
#Display the dictionary in newline for key, value in data_dict.items(): key = key.strip('/').strip('\n') value = value.strip('/').strip('\n') print(f"KEY:{key}: VALUE:{value}<br>") us = data_dict.get('userid') number = data_dict.get('phoneno')JSON input looks as below:
Output:messageId: zZCqqqXvoKx567894QM1
conversationId: XmlgyWS48Qrthuwehs
data: {"action":"submit","userid":"xyxr","phoneno":"567894567"},"formMessageId":"LDFWN_ha-fdfdffdeasqwcsd","formId":"user-details-form"}