Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
bytes to json
#1
Hi
I am trying to send json data over a pipe but cannot get it quite right
Send
mesages = [{"id": "1", "txt": "message 1", "start_date": "2014-02-09", "start_time": "16:20", "duration": "01:00"}]
        win32file.WriteFile(handle,     str.encode(json.dumps(mesages), encoding="ascii"))
receive
 result, data = win32file.ReadFile(p, 65535)
            json_data = json.dumps(data.decode('ascii'))
            print(json_data['first_name'])
This gives me this error
[error
TypeError: string indices must be integers
[/error]

What is the correct way of doing this?
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,717 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