data = data.decode('utf-8')
print(data) # b'1' : {"reciever": "1", "sender:": 1, "seq_num": 7, "data": "2"}
data = data[7:]
print(data) # {"reciever": "1", "sender:": 1, "seq_num": 7, "data": "2"}
data = json.dumps(data)
data = json.loads(data)
print(type(data)) #<class 'str'>
Here is my code. I try to send data (string + json) with socket programming. It sends data well, but I want to use json when receiving messages. So I sliced the json part, and dumps and loads into json. (I imported json) But Its type is still in str.
In my sending function,
result = json.dumps({'reciever' : rec, 'sender:': sender, 'seq_num' : sequence_number, 'data': data})
final_result = json.loads(result)
print(type(final_result)). #dict type
It seems works well here.
Please help !
Thank you