Question : How do you pass a byte array in a JSON request?
Answered by : aman-kumar-verma
import chardet
# check your bytes object encoding
encoding = chardet.detect(your_byte_object)['encoding']
# decode it before saving
data = {"data": your_byte_object.decode(encoding)}
with open('request.txt', 'w') as file: json.dump(data, file)
Source : https://buggyprogrammer.com/ | Last Update : Thu, 11 Aug 22