Python Forum
Beautify dictionary without converting to string.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Beautify dictionary without converting to string.
#1
I m trying to beatuify dicitonary using json.dumps , but as soon as it beautify , the data type changes from dictionary to string. Chnage of datatype to string not allowing it to post on slack channel.

Error while posting it on slack - Str indices must be integer. Point is either I ensure while beatufying data type dont changes or modificaiton be to done at slack configuraton end.


input = {"checkType":"employeePurchase_not_true","output":[{"purchaseType":"ORDER","recordCount":["AU: 1","FR: 1","IT: 11","BE: 1","AT: 1","SE: 1","ES: 1","FI: 1","NL: 1","PT: 1","NO: 1","DE: 2","PL: 1","SI: 1","IE: 1","GB: 7","DK: 1","US: 1","SK: 1","RU: 2","CA: 1","CH: 1"]},{"purchaseType":"RECEIPT","recordCount":["AU: 956","FR: 1","IT: 5","BE: 165","AT: 2","SE: 1","ES: 5765","FI: 1","NL: 2","CZ: 308","HU: 1","KR: 2","NO: 3","IN: 3","DE: 45","PL: 1","SI: 1","JP: 3","GB: 2","RS: 1","DK: 5","US: 762","RU: 442","RO: 1","HR: 13","CA: 3","CH: 36"]}]}
slack_msg["channel"] = "ce-ecd-ops-dataquality"
slack_msg["message"] = input
d=json.dumps(slack_msg,indent=4)    
send_slack_alert(d)
buran write Apr-11-2021, 06:43 AM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Reply


Messages In This Thread
Beautify dictionary without converting to string. - by sharoon - Apr-11-2021, 06:37 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Converting '1a2b3c' string to Dictionary PythonNoobLvl1 6 1,781 May-13-2022, 03:44 PM
Last Post: deanhystad
  Need help converting string to int dedesssse 7 2,617 Jul-07-2021, 09:32 PM
Last Post: deanhystad
  how to deal with problem of converting string to int usthbstar 1 1,935 Jan-05-2021, 01:33 PM
Last Post: perfringo
  Converting data in CSV and TXT to dictionary kam_uk 3 1,956 Dec-22-2020, 08:43 PM
Last Post: bowlofred
  Converting string to hex triplet menator01 4 4,221 Aug-03-2020, 01:00 PM
Last Post: deanhystad
  extract a dictionary from a string berc 4 2,791 Jul-30-2020, 06:58 AM
Last Post: berc
  simple f-string expressions to access a dictionary Skaperen 0 1,499 Jul-15-2020, 05:04 AM
Last Post: Skaperen
  converting string object inside a list into an intiger bwdu 4 2,555 Mar-31-2020, 10:36 AM
Last Post: buran
  problem coverting string data file to dictionary AKNL 22 6,273 Mar-10-2020, 01:27 PM
Last Post: AKNL
  Converting query string as a condition for filter data. shah_entrance 1 1,752 Jan-14-2020, 09:22 AM
Last Post: perfringo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020