Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
bytes to json
#5
Hi
Yes this works, but I am reading from a pipe using
result, data = win32file.ReadFile(p, 65535)
This gives me the string
b'"{\\"success\\": \\"true\\", \\"status\\": 200, \\"message\\": \\"Hello\\"}"'
I then decode
d = data.decode('ascii')
Then I do a json load
json_data = json.loads
but when I try to access as a json object I get the error

TypeError: string indices must be integers
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,709 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