Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
bytes to json
#7
this will work
import json
spam = b'"{\"success\": \"true\", \"status\": 200, \"message\": \"Hello\"}"'
print(spam.decode())
data = json.loads(spam.decode()[1:-1])
print(data['success'])
but I think there is problem with the data being send/receive - i.e. extra quotes. Probably on the sending site you make too many conversions
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
bytes to json - by GrahamL - Dec-04-2020, 09:07 AM
RE: bytes to json - by ndc85430 - Dec-04-2020, 09:29 AM
RE: bytes to json - by GrahamL - Dec-04-2020, 09:53 AM
RE: bytes to json - by DeaD_EyE - Dec-04-2020, 10:39 AM
RE: bytes to json - by GrahamL - Dec-04-2020, 10:44 AM
RE: bytes to json - by GrahamL - Dec-04-2020, 11:22 AM
RE: bytes to json - by buran - Dec-04-2020, 11:46 AM
RE: bytes to json - by GrahamL - Dec-04-2020, 11:59 AM
RE: bytes to json - by buran - Dec-04-2020, 12:13 PM
RE: bytes to json - by GrahamL - Dec-04-2020, 12:13 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  replace bytes with other byte or bytes BigOldArt 1 10,796 Feb-02-2019, 11:00 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

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